标签:TE IV eric leo 单例 代码 脚本 ret private
using System.Collections; using System.Collections.Generic; using UnityEngine; //T为脚本名,可以直接把已经写好的脚本变为单例来用 public class SingleObject<T>where T:class,new() { private static T instance; public static T Instance { get { if(instance==null) { instance = new T(); } return instance; } } }
标签:TE IV eric leo 单例 代码 脚本 ret private
原文地址:https://www.cnblogs.com/fangshiyuanzhucheng/p/9129526.html