Readd missing import files
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using System;
|
||||
|
||||
namespace Wing.Utils
|
||||
{
|
||||
public class MonoSingleton<T> : MonoBehaviour where T : MonoBehaviour
|
||||
{
|
||||
protected static bool s_bEnableAutoCreate = true;
|
||||
protected static T s_pInstance;
|
||||
|
||||
// Use this for initialization
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual void Initialize()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public static T Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
if (s_pInstance == null)
|
||||
{
|
||||
s_pInstance = GameObject.FindObjectOfType<T>();
|
||||
if (s_pInstance == null && s_bEnableAutoCreate)
|
||||
{
|
||||
GameObject singleGO = GameObject.Find("Singletion");
|
||||
if (singleGO == null)
|
||||
{
|
||||
singleGO = new GameObject("Singletion");
|
||||
}
|
||||
|
||||
GameObject instanceObject = new GameObject(typeof(T).Name);
|
||||
instanceObject.transform.SetParent(singleGO.transform);
|
||||
|
||||
s_pInstance = instanceObject.AddComponent<T>();
|
||||
}
|
||||
else if (s_pInstance == null)
|
||||
{
|
||||
//Debug.LogError("empty refrenced in this scene : " + typeof(T).Name);
|
||||
}
|
||||
}
|
||||
return s_pInstance;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user