using System;
using UnityEngine;
public class GameManager : MonoBehaviour
{
private static GameManager _instance;
public static GameManager Instance
{
get { return ObjectInstance.Create(ref _instance); }
}
}
public class ObjectInstance
{
public static T Create<T>(ref T instance)
{
if (instance == null)
{
instance = Activator.CreateInstance<T>();
}
return instance;
}
}
Unity 单例模式 (跳转场景数据依然可用)
猜你喜欢
转载自blog.csdn.net/yzx5452830/article/details/81906469
今日推荐
周排行