fix:代码提初始化
This commit is contained in:
53
Assets/Scripts/SingleInstanceMode/BaseMgr.cs
Normal file
53
Assets/Scripts/SingleInstanceMode/BaseMgr.cs
Normal file
@@ -0,0 +1,53 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class BaseMgr<T>:MonoBehaviour where T : MonoBehaviour
|
||||
{
|
||||
private static T instance;
|
||||
public static T Instance
|
||||
{
|
||||
//get
|
||||
//{
|
||||
// if (instance == null)
|
||||
// instance = new T();
|
||||
// return instance;
|
||||
//}
|
||||
get
|
||||
{
|
||||
//if (instance == null)
|
||||
//{
|
||||
// GameObject obj = new GameObject();
|
||||
// obj.name = typeof(T).ToString();
|
||||
// instance = obj.AddComponent<T>();
|
||||
// DontDestroyOnLoad(obj);
|
||||
//}
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
protected virtual void Awake()
|
||||
{
|
||||
instance = this as T;
|
||||
}
|
||||
//public static T GetInstance()
|
||||
//{
|
||||
// if (instance == null)
|
||||
// instance = new T();
|
||||
// return instance;
|
||||
//}
|
||||
}
|
||||
|
||||
//public class SelfUIManager : MonoBehaviour
|
||||
//{
|
||||
// //public ima
|
||||
// public static GameObject pickUPHint;
|
||||
// private void Awake()
|
||||
// {
|
||||
// if (pickUPHint == null)
|
||||
// {
|
||||
// pickUPHint = GameObject.Find("PickUp");
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
//}
|
||||
Reference in New Issue
Block a user