public static void init() { if( !instance ) { // check if there is a GoKitLite instance already available in the scene graph before creating one instance = FindObjectOfType( typeof( GoKitLite ) ) as GoKitLite; if( !instance ) { var obj = new GameObject( "GoKitLite" ); instance = obj.AddComponent<GoKitLite>(); DontDestroyOnLoad( obj ); } } }
private void OnApplicationQuit() { instance = null; Destroy( gameObject ); }