- Home /
How can I keep a global score updatable from multiple GameObjects
I want to have a scoreboard in my game - and lots of different events in game will adjust this scoreboard. As such it feels like I need a static score variable that is accessible by lots of other Scripts. I am struggling to find the context of this other Script.
I have tried lots of things including:
Making a ScoreHandler empty GameObject - giving it a GUIText and a new script called Data, which has a public int called Score, however no matter what I do - I cannot seem to adjust this Score int from other GameObject scripts!
I am probably just missing an understanding trick here as I am very new to Unity but I would love to know your thoughts.
Answer by TheSituation · Apr 17, 2014 at 11:36 PM
The answer I settled for with the aid of a helpful friend was to simply have a DataManager C# singleton class which could be accessed (as long as I right click resolved the class ) globally by all other classes. Clean. Simple. Thx to my friend!
Your answer
Follow this Question
Related Questions
INCREASE SCORE MORE AND MORE? 1 Answer
Check if a guiText = a number? 2 Answers
Use sprites as score/GUItext? 1 Answer
Scoreboard will not update 1 Answer