public static GlobalScript GetInstance() { if (!Instance) { Instance = (GlobalScript)GameObject.FindObjectOfType(typeof(GlobalScript)); if (!Instance) { Debug.LogError("There needs to be one active MyClass script on a GameObject in your scene."); } Instance.InitPlayer(); } return(Instance); }