您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
24 行
729 B
24 行
729 B
namespace UnityEngine.Experimental.Rendering
|
|
{
|
|
// Use this class to get a static instance of a component
|
|
// Mainly used to have a default instance
|
|
public static class ComponentSingleton<TType>
|
|
where TType : Component
|
|
{
|
|
static TType s_Instance = null;
|
|
public static TType instance
|
|
{
|
|
get
|
|
{
|
|
if (s_Instance == null)
|
|
{
|
|
GameObject go = new GameObject("Default " + typeof(TType)) { hideFlags = HideFlags.HideAndDontSave };
|
|
go.SetActive(false);
|
|
s_Instance = go.AddComponent<TType>();
|
|
}
|
|
|
|
return s_Instance;
|
|
}
|
|
}
|
|
}
|
|
}
|