24 lines
471 B
C#
24 lines
471 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
/// <summary>
|
|
/// 单例
|
|
/// </summary>
|
|
/// <typeparam name="T"></typeparam>
|
|
public class Singleton<T> : MonoBehaviour where T : MonoBehaviour
|
|
{
|
|
public static T Instance
|
|
{
|
|
get
|
|
{
|
|
if (_Instance == null)
|
|
{
|
|
_Instance = FindObjectOfType<T>();
|
|
}
|
|
return _Instance;
|
|
}
|
|
}
|
|
static T _Instance;
|
|
}
|