You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
727 B
35 lines
727 B
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
namespace BuildSystem
|
|
{
|
|
public class MonoSingleton<T> : MonoBehaviour where T : MonoSingleton<T>
|
|
{
|
|
private static T _instance;
|
|
public static T Instance
|
|
{
|
|
get
|
|
{
|
|
return _instance;
|
|
}
|
|
}
|
|
|
|
protected virtual void Awake()
|
|
{
|
|
if (_instance != null)
|
|
{
|
|
Destroy(_instance.gameObject);
|
|
}
|
|
_instance = this as T;
|
|
}
|
|
|
|
protected virtual void OnDestroy()
|
|
{
|
|
if (_instance == this)
|
|
{
|
|
_instance = null;
|
|
}
|
|
}
|
|
}
|
|
}
|