- Home /
ResourceManager problem
So I need a resource manager script to maintain data on various resource types for each player (human and/or computer) and I have a bunch of different objects adding/subtracting resources all the time (again, from their respective resource manager script). At first I thought about using a static class that each other script can reference but quickly remembered that I can't create a separate one for each player (the number of players can also vary). Right now I'm thinking of using a Manager script and placing it within an empty GameObject and having each other script simply reference that GameObject's script component. However I'm sure I'll run into concurrency problems (for example more than one script subtracting from the resource total at one time and therefore possibly creating a negative total) and it also seems inefficient to have all those other objects all referencing the same object's script component. I know very little about 'locking' and I'm not even sure if it would work in this situation.
Is there a better way to go about doing this? Big thanks in advance.
Your answer
Follow this Question
Related Questions
Load can only be called from the main thread 0 Answers
Game Manager - simply use static variables? 0 Answers
Replace asset in Unity resource manager 0 Answers
Instantiating a Coroutine? 2 Answers