创建和继承单例基类

时间:2020-07-11 12:28:05   收藏:0   阅读:59
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PoolMar : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        
    }
}

public class Student <T> where T:new()  
{
    public static T instance;

    public static T MyStudent() 
    {
        if (instance == null)
        {
            instance = new T();
        }

        return instance;
    }
}

public class Student1 :Student<Student1>
{

}

 

原文:https://www.cnblogs.com/yueqingli/p/13282985.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!