add project files
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace OHM.UnityToolkit
|
||||
{
|
||||
public class UniqueInstance<T> : MonoBehaviour
|
||||
{
|
||||
private static UniqueInstance<T> _instance;
|
||||
|
||||
public static T Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
return (_instance is T typed) ? typed : default(T);
|
||||
}
|
||||
}
|
||||
|
||||
public void Awake()
|
||||
{
|
||||
if (_instance != null)
|
||||
{
|
||||
Debug.LogWarning("There is more than one _instance of type " + typeof(T));
|
||||
}
|
||||
else
|
||||
{
|
||||
_instance = this;
|
||||
}
|
||||
AwakeInstance();
|
||||
}
|
||||
|
||||
protected virtual void AwakeInstance()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user