Is there a way I can call this code from all my scripts:
public class Game : MonoBehaviour {
private static Game _instance;
public static Game instance {
get {
if (_instance == null)
_instance = GameObject.FindObjectOfType<Game> ();
return _instance;
}
}
public void Test() {
Debug.Log("Test");
}
}
like this:
Game.Test();
instead of having to do this:
Game.instance.Test()
//Or
Game g = Object.FindObjectOfType<Game>();
if(g != null)
g.Play();