/// <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>
        /// 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>
        /// 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);

                // Check if the list is going outside to the bottom
                if (listWorldCorner[0].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);
                UIUtility.BringToFront(listRect.gameObject);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Focuses this window.
        /// </summary>
        public virtual void Focus()
        {
            if (this.m_IsFocused)
            {
                return;
            }

            // Flag as focused
            this.m_IsFocused = true;

            // Call the static on focused window
            UIWindow.OnBeforeFocusWindow(this);

            // Bring the window forward
            UIUtility.BringToFront(this.gameObject);
        }
        /// <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
            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);
            }
        }
Ejemplo n.º 6
0
        /// <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);
            }
        }
        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;
            TweenEasing easing   = window.transitionEasing;

            // 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() && !this.m_Transitioning)
                {
                    // 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.StartAlphaTween(1f, duration, easing);

                // 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.StartAlphaTween(0f, duration, easing);

                // Toggle block raycast on
                this.m_CanvasGroup.blocksRaycasts = false;
            }
        }