Files
UltimateFishing2020/Assets/Scripts/Assembly-CSharp/Singleton.cs
2026-03-04 10:03:45 +08:00

19 lines
297 B
C#

using UnityEngine;
public class Singleton<T> : MonoBehaviour where T : Component
{
public static T Instance { get; protected set; }
public virtual void Awake()
{
if (Instance == null)
{
Instance = this as T;
}
if (Instance != this)
{
Object.Destroy(base.gameObject);
}
}
}