using UnityEngine; public class GlobalObject : MonoBehaviour { private static GlobalObject _instance; void Awake() { if (_instance == null) { _instance = this; DontDestroyOnLoad(gameObject); } else { Destroy(gameObject); } } }