I have found the following which largely answer my question: http://answers.unity3d.com/questions/740703/when-to-and-when-not-to-use-static-variables.html http://forum.unity3d.com/threads/why-is-static-considered-bad-practice.200363/
What are some best practices for static variables in multiplayer?
I have generally stayed away from using static variables because based on past research they are considered "evil" and should only be used as a last resort.
I am now working on a project involving a login system and the posting of user data (user name, scores etc) and storing it into a database. In the first scene, the login scene, the player username is stored into a variable and the gameobject is set to "dontdestroyonload". In the next scene, the game, several scripts on different gameobjects need to make reference to this script in order to do their job; eg. different UI text elements need to display different user data, the score manager GO needs to be able to post the user data, AI agents need to react/rubberband to the player based on how the player is doing etc etc.
What I am getting at is that there are a tonne of references that need to made for each case and it seems a little silly to be doing this over and over again. The fact that the script initially only exists in the very first scene also complicates this, since FindGameObjectsWithTag needs to be used each time and the one script isolated; all extra unnecessary computation in my opinion. It also seems easier to simply declare user data such as username, score, health as static in one script (since it is always going to be consistent) and then it can easily be called from any script anywhere. I am concerned though, whether using statics can cause any issues in a multiplayer environment, since I will be coding this next, and I am trying to code with this in mind.
So in short:
Static variables for multiplayer; when are they ok to use and what are some common pitfalls to look out for?
Follow this Question
Related Questions
UNET - syncvars 2 Answers
Spawning GameObject on network, locally change it only on the client that spawned it. 0 Answers
How to allow All clients to move blocks? 0 Answers
How to optimize this scripts ? 2 Answers