Since you can not use new() for Monobehaviour, I could not find a way to instanciate my singleton.
public class GameManager : MonoBehaviour
{
private static GameManager instance;
private GameManager() { }
public static GameManager Instance
{
get
{
if (instance == null)
{
instance = gameObjec.AddComponent<GameManager>(); //does not work
}
return instance;
}
}
And it did not work since "An object reference is required for the non-static field, method, or property ‘Component.gameObject’ ".
What should I do then?