I could use a little help thinking about the GUI.
First, are there any recommended best practice tips hiding behind a link somewhere?
Next, more specific questions:
1. Hypothetical situation: you're in a game screen and you hit the pause button. A menu appears with "keep playing" and "exit game" buttons. How should I create this menu? Right now I have it in an off-screen location and make it appear in view when the pause button is pressed. Is there a smarter way to go about this? I've tried enable/disable but every time I try that it seems to elude me because a disabled object doesn't seem to respond to enabling.
2. Buttons. These guys are driving me crazy. So far as I can tell, I have to create button prefabs, drag them into the scene, and control them via a script on a single object (like an empty 'GUI Manager' game object). Here's the script I use on the GUIManager:
public tk2dUIItem PauseBtn;
void OnEnable()
{
if (PauseBtn) {PauseBtn.OnClick += PauseMenu;}
}
I feel like this method requires a lot of duplication of work across several scenes.
This issue probably relates to Unity itself as much as TK2D in that I would like to know how to programatically create these buttons without dragging them to the scene. (I usually end up instantiating and object and not being able to control the clone).
Alternatively, I've tried putting the button control script on the buttons themselves, but this seems to make it harder to control functions across other scripts, which is what led me to the GUI Manager solution. What would you recommend?
3. What is void OnDisable() used for?
Thanks for insight on any of these questions!
Disclaimer: I have a little under 2 years programming experience, am self-taught, and this is the first time I've tried asking a question - please pardon my computer science ignorance :/