Here’s notes from several videos, indicating stuff I want to do or try. Rather than link to each video, let alone an embed, let me shout out EngiGames and Jason Weiman.
- I want to stick my interface in a separate scene. This is contraindicated by EngiGames for small games, but for my RPG, I think it makes sense to have it be its own thing that sits over the top of everything else going on.
using UnityEngine.SceneManagement;
if (SceneManager.GetSceneByName("UI").IsLoaded == false) SceneManager.LoadSceneAsync("UI", LoadSceneMode.Additive);
- Consider, instead, having the menu call
Don'tDestroyOnLoad()
and then swapping immediately to a gameplay scene, rather than monkeying around with additive scenes, though. - If I don’t want to hook up events to buttons using the Unity Button delegates, I can create scripts that handle the button directly. E.g.
// In Start(), using UnityEngine.UI...
button = GetComponent<Button>();
button.onClick.AddListener(YourClickFunctionHere);
- Obviously, I’ll want to be able to grab an instance of some access point to my menu from any other scene. I should be aware that just putting a reference in a public static field in
Awake()
is considered a Very Bad Plan. This is because it is a sloppy singleton that doesn’t do the first part of a singleton’s job — ensure that one, and only one instance of the class exists. This video details a singleton generic that will allow you to turn a Monobehavior into a proper singleton merely by inheriting from it.