For each of my scenes, I have an empty GameObject _Manager
that stores my scripts for setting up the level, keeping track of variables, etc.
On my main screen, I have a play button that isn't instantiated; I simply dragged it into the editor. In my script Main.cs
I have a function Play()
which calls LoadLevel("Game")
. To get my play button to call the Play function, I dragged _Manager
into the onClick slot and selected the function. This worked fine and I have a functional play button.
Unfortunately, this is not working for the prefabbed buttons I need to instantaite in my Game scene. In Game.cs
I have a function LayoutButtons()
which is both public and returns void, yet I am unable to drag _Manager
into the slot on my prefabbed button. Even if I do it before converting the button to a prefab, it simply disappears once it becomes a prefab.
I've managed to work around this by putting my LayoutButtons()
function in a new script which I attached directly to the prefab, but I'd like to keep the function within Game.cs
and attached to my manager object if that's possible.