當類繼承與MonoBehaviour時this
public class TestSingle : MonoBehaviour繼承
{get
public static TestSingle Instance;io
void Awake()class
{static
Instance = this ;vi
}new
}return
當類不繼承與MonoBehaviour時void
public class TestSingle :
{
public static TestSingle instance;
public static TestSingle Instance
{
get
{
if(instance == null)
instance = new TestSingle();
return instance;
}
}
}