IGNORE POST I'm the dumbest human on the planet. My interface gameobject was enabled, but I had *temporarily* disabled the Interface.cs script and thus none of the code I was writing was executing. It works perfectly fine. Sigh.
Hey Guys,
I'm having some issues getting buttons to work. I essentially have a Texture component with an attached Box Collider (adjusted to match button size) and UIEvent Trigger.
From my primary Interface.cs script, I would like to take this texture button, and assign it's callbacks to various functions inside Interface.cs.
Inside Interface.cs, I have something that looks like this:
GameObject helpButton;
...
helpButton = GameObject.Find("HelpButton");
...
EventDelegate.Add(helpButton.GetComponent<UIEventTrigger>().onClick, ShowHowToPlay);
This is with the intention of adding the ShowHowToPlay() function from within Interface.cs to the button's onClick callback.
void ShowHowToPlay() {
howToPlayWindow.SetActive(true);
}
Admittedly, I do not know how to accomplish this, I am piecing things from various sources.. All of which tend to favor the "just drag your component into the event" which isn't flexible enough for things I know I'm going to need.
Is there a way to do this (I assume so), and if so, what have I done wrong?
Thanks!
EDIT: I have been equally as unsuccessful with adding a UIButton component to the texture with a box collider. Although I assume the AddDelegate code would be incorrect for a button.