I need a variable that instantiate an object the first time that you call it. The variable is already part of a singleton.
public class Game_Manager : MonoBehaviour {
public static Game_Manager Instance{get; private set;}
public WaypointRig waypointRig
{
get
{
if (waypointRig == null) waypointRig = new WaypointRig();
return waypointRig;
}
private set{}
}
}
}
But this code creates stackOverflow