using UnityEngine; public class DontDestroy : MonoBehaviour { public static DontDestroy Instance { get; private set; } private void Awake() { if (Instance == null) { Instance = this; DontDestroyOnLoad(gameObject); } else Destroy(gameObject); } }