using System.Collections; using System.Collections.Generic; using UnityEngine; //********************************** //创建人: //功能说明:普通单例基类(懒汉式) //**********************************
publicclassBaseManager<T> whereT : new() { privatestatic T _instance;
publicstatic T Instance { get { if (_instance == null) { _instance = new T(); } return _instance; } }
using System.Collections; using System.Collections.Generic; using UnityEngine; //********************************** //创建人: //功能说明:Mono单例 //********************************** publicclassSingletonMono<T> : MonoBehaviourwhereT : MonoBehaviour { privatestatic T _instance; publicstatic T Instance { get { return _instance; } }
using System.Collections; using System.Collections.Generic; using UnityEngine; //********************************** //创建人: //功能说明:自动Mono单例 //**********************************
publicclassSingletonAutoMono<T> : MonoBehaviourwhereT : MonoBehaviour { privatestatic T _instance; publicstatic T Instance { get { if (_instance == null) { GameObject obj = new GameObject(); obj.name = typeof(T).Name; _instance = obj.AddComponent<T>(); GameObject.DontDestroyOnLoad(obj); } return _instance; } }
using System.Collections; using System.Collections.Generic; using System.Xml.Linq; using UnityEditor.Experimental.GraphView; using UnityEngine; //********************************** //创建人: //功能说明:对象池管理类 //**********************************
///<summary> /// 对象池数据(子对象池) ///</summary> publicclassPoolData { //对象挂载的父节点 public GameObject fatherObj; //对象的容器 public List<GameObject> poolList;
publicPoolData(GameObject obj, GameObject poolObj) { //创建一个新对象,为此对象池对象的父对象 fatherObj = new GameObject(obj.name); fatherObj.transform.SetParent(poolObj.transform); //创建容器并将对象放进容器 poolList = new List<GameObject>(); PushObj(obj); }
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.Events; //********************************** //创建人: //功能说明: //**********************************
using System.Collections; using System.Collections.Generic; using System.ComponentModel; using UnityEngine; using UnityEngine.Events; //********************************** //创建人: //功能说明: //**********************************
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.Events; using UnityEngine.SceneManagement; //********************************** //创建人: //功能说明: //**********************************