private void OnProgressChange(float value) { if (this.m_TooltipObject == null || this.m_ProgressBar == null) { return; } RectTransform tooltipRect = (this.m_TooltipObject.transform as RectTransform); RectTransform fillRect = (this.m_ProgressBar.type == UIProgressBar.Type.Filled ? (this.m_ProgressBar.targetImage.transform as RectTransform) : this.m_ProgressBar.targetTransform); // Change the parent so we can calculate the position correctly tooltipRect.SetParent(fillRect, true); // Change the position based on fill tooltipRect.anchoredPosition = new Vector2(fillRect.rect.width * value, this.m_OffsetY); // Bring to top UIUtility.BringToFront(this.m_TooltipObject); // Set the percent text if (this.m_PercentText != null) { this.m_PercentText.text = (value * 100f).ToString("0") + "%"; } }
/// <summary> /// Raises the tooltip event. /// </summary> /// <param name="show">If set to <c>true</c> show.</param> public virtual void OnTooltip(bool show) { if (this.m_TooltipObject == null || this.m_FillImage == null) { return; } RectTransform tooltipRect = (this.m_TooltipObject.transform as RectTransform); RectTransform fillRect = (this.m_FillImage.transform as RectTransform); if (show) { // Change the parent so we can calculate the position correctly tooltipRect.SetParent(this.m_FillImage.transform, true); // Change the position based on fill tooltipRect.anchoredPosition = new Vector2(fillRect.rect.width * this.m_FillImage.fillAmount, this.m_OffsetY); // Bring to top UIUtility.BringToFront(this.m_TooltipObject); // Enable the tooltip this.m_TooltipObject.SetActive(true); } else { // Disable the tooltip this.m_TooltipObject.SetActive(false); } }
/// <summary> /// Positions the list for the given direction (Auto is not handled in this method). /// </summary> /// <param name="direction">Direction.</param> public virtual void PositionListForDirection(Direction direction) { // Make sure the creating of the list was successful if (this.m_ListObject == null) { return; } // Get the list rect transforms RectTransform listRect = (this.m_ListObject.transform as RectTransform); // Determine the direction of the pop if (direction == Direction.Auto) { // Get the list world corners Vector3[] listWorldCorner = new Vector3[4]; listRect.GetWorldCorners(listWorldCorner); Vector2 screenPoint = RectTransformUtility.WorldToScreenPoint(Camera.main, listWorldCorner[0]); // Check if the list is going outside to the bottom if (screenPoint.y < 0f) { direction = Direction.Up; } else { direction = Direction.Down; } } // Handle up or down direction if (direction == Direction.Down) { listRect.SetParent(this.transform, true); listRect.pivot = new Vector2(0f, 1f); listRect.anchorMin = new Vector2(0f, 0f); listRect.anchorMax = new Vector2(0f, 0f); listRect.anchoredPosition = new Vector2(listRect.anchoredPosition.x, this.listMargins.top * -1f); UIUtility.BringToFront(listRect.gameObject); } else { listRect.SetParent(this.transform, true); listRect.pivot = new Vector2(0f, 0f); listRect.anchorMin = new Vector2(0f, 1f); listRect.anchorMax = new Vector2(0f, 1f); listRect.anchoredPosition = new Vector2(listRect.anchoredPosition.x, this.listMargins.bottom); if (this.m_StartSeparatorObject != null) { this.m_StartSeparatorObject.transform.SetAsLastSibling(); } UIUtility.BringToFront(listRect.gameObject); } }
/// <summary> /// Shows the tooltip. /// </summary> protected virtual void Internal_Show() { // Create the attribute rows this.EvaluateAndCreateTooltipLines(); // Update the tooltip position this.UpdatePositionAndPivot(); // Bring forward UIUtility.BringToFront(this.gameObject); // Transition this.EvaluateAndTransitionToState(true, false); }
/// <summary> /// Toggles the list. /// </summary> /// <param name="state">If set to <c>true</c> state.</param> protected virtual void ToggleList(bool state) { if (!this.IsActive()) { return; } // Check if the list is not yet created if (this.m_ListObject == null) { this.CreateList(); } // Make sure the creating of the list was successful if (this.m_ListObject == null) { return; } // Make sure we have the canvas group if (this.m_ListCanvasGroup != null) { // Disable or enable list interaction this.m_ListCanvasGroup.blocksRaycasts = state; } // Bring to front if (state) { UIUtility.BringToFront(this.m_ListObject); } // Start the opening/closing animation if (this.listAnimationType == ListAnimationType.None || this.listAnimationType == ListAnimationType.Fade) { float targetAlpha = (state ? 1f : 0f); // Fade In / Out this.TweenListAlpha(targetAlpha, ((this.listAnimationType == ListAnimationType.Fade) ? this.listAnimationDuration : 0f), true); } else if (this.listAnimationType == ListAnimationType.Animation) { this.TriggerListAnimation(state ? this.listAnimationOpenTrigger : this.listAnimationCloseTrigger); } }
/// <summary> /// Show this cast bar. /// </summary> /// <param name="instant">If set to <c>true</c> instant.</param> public virtual void Show(bool instant) { // Bring to the front if (this.m_BrindToFront) { UIUtility.BringToFront(this.gameObject); } // Do the transition if (instant || this.m_InTransition == Transition.Instant) { // Set the canvas group alpha this.m_CanvasGroup.alpha = 1f; } else { // Start a tween this.StartAlphaTween(1f, this.m_InTransitionDuration, true); } }
/// <summary> /// Raises the tooltip event. /// </summary> /// <param name="show">If set to <c>true</c> show.</param> public virtual void OnTooltip(bool show) { if (this.m_TooltipObject == null) { return; } if (show) { // Bring to top UIUtility.BringToFront(this.m_TooltipObject); // Enable the tooltip this.m_TooltipObject.SetActive(true); } else { // Disable the tooltip this.m_TooltipObject.SetActive(false); } }
/// <summary> /// Toggles the list. /// </summary> /// <param name="state">If set to <c>true</c> state.</param> protected virtual void ToggleList(bool state) { if (!this.IsActive()) { return; } // Check if the list is not yet created if (this.m_ListObject == null) { this.CreateList(); } // Make sure the creating of the list was successful if (this.m_ListObject == null) { return; } // Make sure we have the canvas group if (this.m_ListCanvasGroup != null) { // Disable or enable list interaction this.m_ListCanvasGroup.blocksRaycasts = state; } // Make sure navigation is enabled in open state if (state) { this.m_LastNavigationMode = this.navigation.mode; this.m_LastSelectedGameObject = EventSystem.current.currentSelectedGameObject; Navigation newNav = this.navigation; newNav.mode = Navigation.Mode.Vertical; this.navigation = newNav; // Set the select field as selected EventSystem.current.SetSelectedGameObject(this.gameObject); } else { Navigation newNav = this.navigation; newNav.mode = this.m_LastNavigationMode; this.navigation = newNav; if (this.m_LastSelectedGameObject != null) { EventSystem.current.SetSelectedGameObject(this.m_LastSelectedGameObject); } } // Bring to front if (state) { UIUtility.BringToFront(this.m_ListObject); } // Start the opening/closing animation if (this.listAnimationType == ListAnimationType.None || this.listAnimationType == ListAnimationType.Fade) { float targetAlpha = (state ? 1f : 0f); // Fade In / Out this.TweenListAlpha(targetAlpha, ((this.listAnimationType == ListAnimationType.Fade) ? this.listAnimationDuration : 0f), true); } else if (this.listAnimationType == ListAnimationType.Animation) { this.TriggerListAnimation(state ? this.listAnimationOpenTrigger : this.listAnimationCloseTrigger); } }
/// <summary> /// Brings the window to the front. /// </summary> public void BringToFront() { UIUtility.BringToFront(this.gameObject, this.m_FocusAllowReparent); }
public void OnTransitionBegin(UIWindow window, UIWindow.VisualState state, bool instant) { if (!this.IsActive() || window == null) { return; } // Check if we are receiving hide event and we are not showing the overlay to begin with, return if (state == UIWindow.VisualState.Hidden && !this.IsVisible()) { return; } // Prepare transition duration float duration = (instant) ? 0f : window.transitionDuration; // Showing a window if (state == UIWindow.VisualState.Shown) { // Increase the window count so we know when to hide the overlay this.m_WindowsCount += 1; // Check if the overlay is already visible if (this.IsVisible()) { // Bring the window forward UIUtility.BringToFront(window.gameObject); // Break return; } // Bring the overlay forward UIUtility.BringToFront(this.gameObject); // Bring the window forward UIUtility.BringToFront(window.gameObject); // Transition this.m_Image.CrossFadeAlpha(1f, duration, true); // Toggle block raycast on this.m_CanvasGroup.blocksRaycasts = true; } // Hiding a window else { // Decrease the window count this.m_WindowsCount -= 1; // Never go below 0 if (this.m_WindowsCount < 0) { this.m_WindowsCount = 0; } // Check if we still have windows using the overlay if (this.m_WindowsCount > 0) { return; } // Transition this.m_Image.CrossFadeAlpha(0f, duration, true); // Toggle block raycast on this.m_CanvasGroup.blocksRaycasts = false; } }