您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
26 行
616 B
26 行
616 B
namespace UnityEngine.Experimental.Rendering
|
|
{
|
|
[ExecuteInEditMode]
|
|
public abstract class Singleton<T> : ScriptableObject where T : ScriptableObject
|
|
{
|
|
private static T theInstance { get; set; }
|
|
|
|
protected static T instance
|
|
{
|
|
get
|
|
{
|
|
LoadAsset();
|
|
return theInstance;
|
|
}
|
|
}
|
|
|
|
static void LoadAsset()
|
|
{
|
|
if (!theInstance)
|
|
{
|
|
theInstance = CreateInstance<T>();
|
|
theInstance.hideFlags = HideFlags.HideAndDontSave;
|
|
}
|
|
}
|
|
}
|
|
}
|