using UnityEngine; public class SingletonExample : MonoBehaviour { private static SingletonExample _instance; void Awake(){ if (_instance == null){ _instance = this; DontDestroyOnLoad(this.gameObject); //Rest of your Awake code } else { Destroy(this); } } //Rest of your class code }