| 12345678910111213141516171819202122232425 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public abstract class MonoSingleton<T> : MonoBehaviour where T : MonoBehaviour
- {
- private static T instance = null;
- public static T GetInstance()
- {
- if (null == instance)
- {
- instance = FindObjectOfType(typeof(T)) as T;
- if (instance == null)
- {
- instance = new GameObject(typeof(T).ToString() + "Obj", typeof(T)).GetComponent<T>();
- }
- }
- return instance;
- }
- public virtual void InitManager()
- {
- }
- }
|