public class Gamemanager : MonoBehaviour {
public static Gamemanager instance; [SerializeField] private void Awake(){
if(instance == null) // if instance is not initilized then instance is equal to class
instance =this;
}
}//classs
public class Gamemanager : MonoBehaviour {
public static Gamemanager instance; [SerializeField] private void Awake(){
if(instance == null) // if instance is not initilized then instance is equal to class
instance =this;
}
}//classs
Basically we want to make sure that the static (!) "instance" variable will always hold the reference to the same instance of the Gamemanager no matter what, even if for some reason, multiple instances of Gamemanager are created. As it has been mentioned above, this is also called "Singleton pattern".