Je suis entrain de tester le mot-clés "static". J'ai deux scripts Test et AfficheTest, AfficheTest affiche dans la console la valeur de la variable t du script Test.
Code : Tout sélectionner
public class Test : MonoBehaviour
{
public static Test test;
public string t;
void Awake() { t = "test" }
}
Code : Tout sélectionner
public class AfficheStatic : MonoBehaviour {
// Use this for initialization
void Start ()
{
Debug.Log(Test.test.t);
}
}
Code : Tout sélectionner
NullReferenceException: Object reference not set to an instance of an object
AfficheStatic.Start () (at Assets/Script/AfficheStatic.cs:10)