using System.Collections; using System.Collections.Generic; using UnityEngine; namespace HJDFrameWork { public class MonoSingleton : MonoBehaviour where T : MonoSingleton, new() { static T instance; public static T Instance { get { if (instance == null) { GameObject go = new GameObject(typeof(T).Name); instance = go.AddComponent(); if (GameObject.Find("InstanceGroup") != null) { go.transform.SetParent(GameObject.Find("InstanceGroup").transform); } else { GameObject pearent = new GameObject("InstanceGroup"); go.transform.SetParent(pearent.transform); } } return instance; } } } }