- Home /
Question by
AwesomeFaceHD · Mar 20, 2014 at 04:03 PM ·
c#variableaccessglobalvariables
Access a variable easily from anywhere
I want to be able to make a variable for the character's name that the player will choose, then easily be able to put it anywhere, something like %playerName%(not exactly that, just showing what I mean) just in any script. Is there an easy way to do this? By the way, I use C#. Thanks in advance.
Comment
Best Answer
Answer by MousePods · Mar 20, 2014 at 04:11 PM
I would just make a script called GameData and put it on the camera.
Then any script that needs it can access it:
void Start()
{
playerName = Camera.main.getComponent<GameData>().playerName;
}