Hello,
I’ve a script attached to a gameobject, this script called “testvar.cs” and contains:
public int great = 123;
Now I need to change “great” value from 123 to 2, from another script, and I’m using this line:
playerPrefab.GetComponent<testvar>().great = 2;
playerPrefab is a the public gameobject (set with the inspector)where I’ve “testvar.cs” script.
By the way that line of code always produce NullReferenceException.
Where is the error ? Thanks