I’m using unity 4.6 and I would like to access the button component of a button so I can set it’s interactable bool in it when the game reaches certain conditions but there does not seem to be a Button class that I can access so I cannot get a reference to the button. Does anyone know how to access the button component?
You need to import UnityEngine.UI in addition to UnityEngine to see the Button class in auto-completion.
interactable is a member of UI.Selectable attach the following to your button to have debug display its state:
using UnityEngine;
using UnityEngine.UI;
public class interactTest : MonoBehaviour {
Selectable button;
void OnEnable () {
button = gameObject.GetComponent<Selectable>();
Debug.Log(button.interactable.ToString());
}
}