34 lines
686 B
C#
34 lines
686 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
/// <summary>
|
|
/// µ¥ÀýÀà
|
|
/// </summary>
|
|
namespace ZXK.GYJQR
|
|
{
|
|
public class Singleton<T> : MonoBehaviour where T : MonoBehaviour
|
|
{
|
|
private static T _instance = null;
|
|
protected Singleton() { }
|
|
public static T Instance
|
|
{
|
|
get
|
|
{
|
|
return _instance;
|
|
}
|
|
}
|
|
|
|
private void Awake()
|
|
{
|
|
if (_instance == null)
|
|
{
|
|
_instance = gameObject.GetComponent<T>();
|
|
}
|
|
else
|
|
{
|
|
Destroy(gameObject);
|
|
}
|
|
}
|
|
}
|
|
}
|