Browse Source

添加namespace

胡佳骏 1 year ago
parent
commit
c1d6181ad5
1 changed files with 23 additions and 20 deletions
  1. 23 20
      package/Samples~/YIYANDemo/Scripts/MonoSingleton.cs

+ 23 - 20
package/Samples~/YIYANDemo/Scripts/MonoSingleton.cs

@@ -1,33 +1,36 @@
 using UnityEngine;
 
-
-public abstract class MonoSingleton<T> : MonoBehaviour where T : MonoBehaviour
+namespace yiyan
 {
-    public bool global = true;
-    static T instance;
-    protected bool _isInit = false;
-    public static T Instance
+    public abstract class MonoSingleton<T> : MonoBehaviour where T : MonoBehaviour
     {
-        get
+        public bool global = true;
+        static T instance;
+        protected bool _isInit = false;
+        public static T Instance
         {
-            if (instance == null)
+            get
             {
-                instance =(T)FindObjectOfType<T>();
+                if (instance == null)
+                {
+                    instance = (T)FindObjectOfType<T>();
+                }
+                return instance;
             }
-            return instance;
-        }
 
-    }
+        }
 
-    void Start()
-    {
-        if (global) DontDestroyOnLoad(this.gameObject);
-        Debug.Log(this.gameObject.name);
-        this.OnStart();
-    }
+        void Start()
+        {
+            if (global) DontDestroyOnLoad(this.gameObject);
+            Debug.Log(this.gameObject.name);
+            this.OnStart();
+        }
 
-    protected virtual void OnStart()
-    {
+        protected virtual void OnStart()
+        {
 
+        }
     }
+
 }