private bool CreateInstance(out GameGizmo.Instance instance, Type type) { bool flag; try { instance = this.ConstructInstance(); if (!object.ReferenceEquals(instance, null)) { if (this._instances == null) { this._instances = new HashSet <GameGizmo.Instance>(); } this._instances.Add(instance); if (!type.IsAssignableFrom(instance.GetType())) { this.DestroyInstance(instance); throw new InvalidCastException(); } return(true); } else { flag = false; } } catch (Exception exception) { Debug.LogException(exception, this); instance = null; flag = false; } return(flag); }
private bool DestroyInstance(GameGizmo.Instance instance) { if (object.ReferenceEquals(instance, null) || this._instances == null || !this._instances.Remove(instance)) { return(false); } try { instance.ClearResources(); this.DeconstructInstance(instance); } catch (Exception exception) { Debug.LogException(exception, this); } return(true); }
protected virtual void DeconstructInstance(GameGizmo.Instance instance) { }