/// <summary> /// Close this widget. /// </summary> public virtual void Close() { if (!m_IsShowing) { return; } m_IsShowing = false; TweenCanvasGroupAlpha(m_CanvasGroup.alpha, 0f); TweenTransformScale(m_RectTransform.localScale, Vector3.zero); WidgetUtility.PlaySound(this.m_CloseSound, 1.0f); m_CanvasGroup.interactable = false; m_CanvasGroup.blocksRaycasts = false; if (this.m_ShowAndHideCursor) { m_CurrentVisibleWidgets.Remove(this); if (m_CurrentVisibleWidgets.Count == 0) { //Cursor.lockState = m_PreviousCursorLockMode; //Cursor.visible = m_PreviousCursorVisibility; if (this.m_CameraController != null) { this.m_CameraTransform.SendMessage("Deactivate", this.m_CameraPreset, SendMessageOptions.DontRequireReceiver); //this.m_CameraController.enabled = m_PreviousCameraControllerEnabled; if (this.m_CameraController.enabled && this.m_FocusPlayer) { this.m_CameraController.SendMessage("Focus", false, SendMessageOptions.DontRequireReceiver); } } } } Execute("OnClose", new CallbackEventData()); }
/// <summary> /// Show this widget. /// </summary> public virtual void Show() { if (this.m_IsShowing) { return; } this.m_IsShowing = true; gameObject.SetActive(true); if (this.m_Focus) { Focus(); } TweenCanvasGroupAlpha(m_CanvasGroup.alpha, 1f); TweenTransformScale(Vector3.ClampMagnitude(m_RectTransform.localScale, 1.9f), Vector3.one); WidgetUtility.PlaySound(this.m_ShowSound, 1.0f); m_CanvasGroup.interactable = true; m_CanvasGroup.blocksRaycasts = true; Canvas.ForceUpdateCanvases(); for (int i = 0; i < this.m_Scrollbars.Length; i++) { this.m_Scrollbars[i].value = 1f; } if (this.m_ShowAndHideCursor) { if (m_CurrentVisibleWidgets.Count == 0) { m_PreviousCursorLockMode = Cursor.lockState; m_PreviousCursorVisibility = Cursor.visible; if (m_CameraController != null) { m_PreviousCameraControllerEnabled = m_CameraController.enabled; } } m_CurrentVisibleWidgets.Add(this); if (m_CameraController != null && !Input.GetKey(this.m_Deactivate)) { this.m_CameraController.enabled = false; if (this.m_FocusPlayer) { this.m_CameraController.SendMessage("Focus", true, SendMessageOptions.DontRequireReceiver); } } Cursor.lockState = CursorLockMode.None; Cursor.visible = true; } Execute("OnShow", new CallbackEventData()); }
/// <summary> /// Close this widget. /// </summary> public virtual void Close() { if (!m_IsShowing) { return; } m_IsShowing = false; TweenCanvasGroupAlpha(m_CanvasGroup.alpha, 0f); TweenTransformScale(m_RectTransform.localScale, Vector3.zero); WidgetUtility.PlaySound(closeSound, 1.0f); m_CanvasGroup.interactable = false; m_CanvasGroup.blocksRaycasts = false; if (onClose != null) { onClose.Invoke(); } }
/// <summary> /// Show this widget. /// </summary> public virtual void Show() { if (m_IsShowing) { return; } m_IsShowing = true; gameObject.SetActive(true); if (m_Focus) { Focus(); } TweenCanvasGroupAlpha(m_CanvasGroup.alpha, 1f); TweenTransformScale(Vector3.ClampMagnitude(m_RectTransform.localScale, 1.9f), Vector3.one); WidgetUtility.PlaySound(showSound, 1.0f); m_CanvasGroup.interactable = true; m_CanvasGroup.blocksRaycasts = true; if (onShow != null) { onShow.Invoke(); } }