private void OnDestroy() { if (this == _instance) { _instance = null; _isDestroyed = true; } Destroy(this); }
private void Awake() { if (_instance == null) { _instance = gameObject.GetComponent <PermissionPlugin>(); } else if (_instance != this) { _instance.OnDestroy(); _instance = gameObject.GetComponent <PermissionPlugin>(); } DontDestroyOnLoad(this); Initialize(); }