private void OnDestroy() { if (main == this) { main = null; } }
// Start is called before the first frame update public void Awake() { if (main != null) { Destroy(gameObject); } else { main = this; } }