void OnDestroy() { if (I == this) { I = null; elements = MinigamesUIElement.Unset; } showTween.Kill(); }
/// <summary> /// Instantiates the Minigames UI in a scene, with the given parameters. /// The minigames UI is destroyed when a new scene is loaded. /// <para> /// NOTE: calling this method when a MinigamesUI is already in the scene will destroy the current one and create a new one. /// </para> /// NOTE: after calling this method, you will have to call the <code>Setup</code> method on each separate element /// (except for Starbar that doesn't need it). /// </summary> /// <param name="_elements">UI elements, uses Flag enum. For example, to activate both Starbar and Timer, use: /// <para><code>Init(MinigamesUIElement.Starbar | MinigamesUIElement.Lives);</code></para> /// while to activate only the Timer, call: /// <para><code>Init(MinigamesUIElement.Timer);</code></para> /// </param> public static void Init(MinigamesUIElement _elements) { if (I != null) { Destroy(I.gameObject); } elements = _elements; GameObject go = Instantiate(Resources.Load <GameObject>(ResourcePath)); go.name = "[MinigamesUI]"; I = go.GetComponent <MinigamesUI>(); }
bool HasElement(MinigamesUIElement _element) { return((elements & _element) == _element); }