private void _EnsureDestroy() { if (this._awake) { if (!this._lock_destroy) { try { try { this._lock_destroy = true; if (this.closeButtonListener) { this.closeButtonListener.onClick -= this.buttonCallback; } if (!this._closed) { this._showWithRPOS = false; this._showWithoutRPOS = false; this.CheckDisplay(); if (this._opened && !this._closed) { this.WindowClose(); } } this.WindowDestroy(); } catch (Exception exception1) { Exception exception = exception1; Debug.LogError(string.Format("A exception was thrown during window destroy ({0}, title={1}) and potentially screwed up stuff, exception is below\r\n{2}", this, this.TitleText, exception), this); } } finally { this._destroyed = true; this._lock_destroy = false; RPOS.UnregisterWindow(this); } } else { Debug.LogWarning("Something tried to destroy while this window was destroying", this); } } else if (this._lock_awake) { Debug.LogWarning("This window was awakening.. the call to destroy will happen when its done. Look at call stack. Avoid this.", this); this._destroyAfterAwake = true; } else if (!this._lock_destroy) { this._lock_destroy = true; Debug.LogWarning("This window is being destroyed, and has never got it's Awake.", this); } }