核心:
1.定义一个静态的对象,在外界访问,在内部构建
2.构造方法私有化
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class UIManager
{
private static UIManager _instance = null;
public static UIManager Instance
{
get
{
if (_instance == null)
{
_instance = new UIManager();
}
return _instance;
}
}
private UIManager()
{
}
}