|
@@ -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()
|
|
|
+ {
|
|
|
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
}
|