I have a script attached to a prefab (and the prefab is loaded to scene during runtime)… they have a script called “Class_Cube”. I want to access to a script “Main” attached to a empty in the gameScene called Game Controller. and play an audio source… How can I do that?
(Long Explanation: I have some cubes in my game, and when you play correctly they go to combo mode… in that they make like a heartbeat animation, and i want the game to play a clip everytime it pulses…)
I’m not sure what part you’re having a problem with.
At load time you can use Find() to find GameObjects in the scene (not ideal but it works), or you can make a container that has references to the GameObjects you’re interested in, and have everything else look in that container.
Or you can use Find() at load time to create the container that everybody else knows to refer to via some kind of singleton pattern? I guess I don’t understand what part you’re having trouble with from your original point.