Hi All,
I just wonder what is the difference between regular c# class that has only static method and members to be used as kind of singleton manger and “true” singleton class.
Say I have the following singleton:
public class MySingelton : MonoBehaviour {
private static MySingelton instance;
public static MySingelton Instance
{
get
{
if (instance == null)
{
GameObject go = new GameObject("MySingelton");
instance = go.AddComponent<MySingelton>();
}
return instance;
}
}
void Awake()
{
if (instance == null){
instance = this;
}
}
and say I have class that has only static methods and members:
public class Manager
{
only static method and members
}
what is the differences between the 2 approaches? what are the pros and cons of each other? besides the fact that one class is instantiate on game object and the other on is not I don’t see any difference. Am I wrong? I try to figure it out for the last couple of hours…
Thank u in advance