16 lines
311 B
C#
16 lines
311 B
C#
using UnityEngine;
|
|
|
|
public class SingletonBehaviour<T> : MonoBehaviour where T : SingletonBehaviour<T>
|
|
{
|
|
public static T Instance
|
|
{
|
|
get;
|
|
private set;
|
|
}
|
|
|
|
protected virtual void Awake()
|
|
{
|
|
if (!Instance) Instance = this as T;
|
|
else Destroy(gameObject);
|
|
}
|
|
} |