- Home /
How do I store a public reference to a GameObject/GameObject's Component?
I'm using a GameObject named GameHandler with all game-related scripts inside (pause handler, inventory renderer...). Certain prefabs (not present in the scene) need to store a reference to these components (or a single reference to the GameHandler). Though, I can't find the GameHandler using a script, as it is a root object in the scene.
So, is there a way to store publicly accessible references to objects, or do I have to find the GameHandler every time? If so, then how do I get it from the scene root? Or is there any other, much better way of storing game-handling scripts, which then can be accessed?
Thanks!
Answer by FortisVenaliter · Aug 29, 2017 at 08:40 PM
You want to use the Singleton Design Pattern.
Your answer
Follow this Question
Related Questions
One Script Referred by Another Script used by Multiple Objects 0 Answers
How do I access two Scripts 1 Answer
Cannot use System.data as reference 0 Answers