Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
44 lines (36 sloc) 1.02 KB
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class NPCSetButton : MonoBehaviour {
[SerializeField]
private List<Button> buttons = new List<Button>();
private List<Text> buttonsText = new List<Text>();
private void Start()
{
for (int i = 0; i < buttons.Count; i++)
{
buttonsText.Add(buttons[i].GetComponentInChildren<Text>());
buttons[i].gameObject.SetActive(false);
}
}
public void disableButtons()
{
for (int i = 0; i < buttons.Count; i++)
{
buttons[i].gameObject.SetActive(false);
}
}
public Button SetButtonText(string buttonText)
{
for (int i = 0; i < buttons.Count; i++)
{
if (buttons[i].gameObject.activeSelf)
continue;
buttonsText[i].text = buttonText;
buttons[i].gameObject.SetActive(true);
return buttons[i];
}
return null;
}
}
You can’t perform that action at this time.