28 lines
437 B
C#
28 lines
437 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
//需求知识:泛型,单例基础知识
|
|
//单例基础框架
|
|
public class BaseManager<T> where T:new()//泛型约束,必须要有无参构造函数
|
|
{
|
|
private static T instance;
|
|
|
|
public static T GetInstance()
|
|
{
|
|
if(instance == null)
|
|
{
|
|
instance = new T();
|
|
}
|
|
return instance;
|
|
}
|
|
|
|
}
|
|
|
|
public class Gam : BaseManager<Gam>
|
|
{
|
|
|
|
|
|
}
|
|
|