/// <summary> /// A coroutine used to toggle the menu /// </summary> /// <param name="active"></param> /// <returns></returns> protected virtual IEnumerator ToggleCo(bool active) { if (_toggling) { yield break; } if (!active) { OnOpenEvent?.Invoke(); _containerRect.gameObject.SetActive(true); } _toggling = true; Active = active; _newPosition = active ? _offPosition : _initialContainerPosition; MMTween.MoveRectTransform(this, _containerRect, _containerRect.localPosition, _newPosition, null, 0f, Data.ToggleDuration, Data.ToggleCurve, ignoreTimescale: true); yield return(MMCoroutine.WaitForUnscaled(Data.ToggleDuration)); if (active) { OnCloseEvent?.Invoke(); _containerRect.gameObject.SetActive(false); } Active = !active; _toggling = false; }
/// <summary> /// A coroutine used to toggle the menu /// </summary> /// <param name="active"></param> /// <returns></returns> protected virtual IEnumerator ToggleCo(bool active) { if (_toggling) { yield break; } if (!active) { _containerRect.gameObject.SetActive(true); } _toggling = true; Active = active; _newPosition = active ? _offPosition : _initialContainerPosition; MMTween.MoveRectTransform(this, _containerRect, _containerRect.localPosition, _newPosition, null, 0f, Data.ToggleDuration, Data.ToggleCurve); yield return(_toggleWFS); if (active) { _containerRect.gameObject.SetActive(false); } Active = !active; _toggling = false; }