using UnityEngine; public class SingeltonObject : MonoBehaviour { void Awake() { SetUpSingelton(); } private void SetUpSingelton() { if (FindObjectsOfType(GetType()).Length > 1) { Destroy(gameObject); } else { DontDestroyOnLoad(gameObject); } } }