Exemplo n.º 1
0
    private IEnumerator ScrollUIElements(UIDirection uiDirection)
    {
        autoScrollActive = true;
        float timeBeforeAutoScroll = .6f;

        MoveToNextElemt(uiDirection);

        while (timeBeforeAutoScroll > 0)
        {
            if (!IsScrollActive(uiDirection))
            {
                autoScrollActive = false;
                yield break;
            }
            timeBeforeAutoScroll -= Time.unscaledDeltaTime;

            yield return(new WaitForEndOfFrame());
        }

        timeBeforeAutoScroll = .07f;
        float nextScrollTimer = 0;

        while (IsScrollActive(uiDirection))
        {
            if (nextScrollTimer <= 0)
            {
                nextScrollTimer = timeBeforeAutoScroll;
                MoveToNextElemt(uiDirection);
            }
            yield return(new WaitForEndOfFrame());

            nextScrollTimer -= Time.unscaledDeltaTime;
        }
        autoScrollActive = false;
    }
Exemplo n.º 2
0
    private void MoveToNextElemt(UIDirection direction)
    {
        UINode uiNodeToMoveTo = null;

        switch (direction)
        {
        case UIDirection.Up:
            uiNodeToMoveTo = currentNodeSelected.GetNodeUp();
            break;

        case UIDirection.Down:
            uiNodeToMoveTo = currentNodeSelected.GetNodeDown();
            break;

        case UIDirection.Right:
            uiNodeToMoveTo = currentNodeSelected.GetNodeRight();
            break;

        case UIDirection.Left:
            uiNodeToMoveTo = currentNodeSelected.GetNodeLeft();
            break;
        }

        if (uiNodeToMoveTo == null)
        {
            return;
        }
        this.currentNodeSelected = uiNodeToMoveTo;
    }
Exemplo n.º 3
0
    public static Rect GetSide(this Rect _self, UIDirection _sideDirection, float _side, float _offset = 0)
    {
        switch (_sideDirection)
        {
        case UIDirection.MiddleCenter:
            return(new Rect(_self.x + _side / 2, _self.y + _side / 2, _self.width - _side, _self.height - _side));

        case UIDirection.Top:
            return(new Rect(_self.x + _side / 2, _self.y - _side / 2 + _offset, _self.width - _side, _side));

        case UIDirection.Bottom:
            return(new Rect(_self.x + _side / 2, _self.y + _self.height - _side / 2 + _offset, _self.width - _side, _side));

        case UIDirection.Left:
            return(new Rect(_self.x - _side / 2 + _offset, _self.y + _side / 2, _side, _self.height - _side));

        case UIDirection.Right:
            return(new Rect(_self.x + _self.width - _side / 2 + _offset, _self.y + _side / 2, _side, _self.height - _side));

        case UIDirection.TopLeft:
            return(new Rect(_self.x - _side / 2 + _offset, _self.y - _side / 2 + _offset, _side, _side));

        case UIDirection.TopRight:
            return(new Rect(_self.x + _self.width - _side / 2 + _offset, _self.y - _side / 2 + _offset, _side, _side));

        case UIDirection.BottomLeft:
            return(new Rect(_self.x - _side / 2 + _offset, _self.y + _self.height - _side / 2 + _offset, _side, _side));

        case UIDirection.BottomRight:
            return(new Rect(_self.x + _self.width - _side / 2 + _offset, _self.y + _self.height - _side / 2 + _offset, _side, _side));
        }
        return(new Rect());
    }
Exemplo n.º 4
0
 public void DisableSide(UIDirection _direction)
 {
     enabledSides &= ~_direction;
     if (Sides.ContainsKey(_direction))
     {
         Sides.Remove(_direction);
     }
 }
Exemplo n.º 5
0
 public void Init(float x, float y, UIDirection growDirection = UIDirection.RightThenUp, float maxWidth = 99999f, float gap = 4f)
 {
     this.growDirection = growDirection;
     startX             = x;
     curX          = x;
     curY          = y;
     this.maxWidth = maxWidth;
     this.gap      = gap;
 }
Exemplo n.º 6
0
        public UIPage(UIDirection direction, UIPageHeight height)
        {
            this.Name = GiveName();

            if (direction == UIDirection.FROM_LEFT)
            {
                this.Idle = new UIIdlePage()
                {
                    Float           = Float.TOP_CENTER,
                    Width           = Styles.Width_Page,
                    Top             = Styles.Top_Page,
                    Right           = Styles.Screen_Width,
                    BackgroundColor = Media.colorWhite
                };
            }
            else if (direction == UIDirection.FROM_RIGHT)
            {
                this.Idle = new UIIdlePage()
                {
                    Float           = Float.TOP_CENTER,
                    Width           = Styles.Width_Page,
                    Top             = Styles.Top_Page,
                    Left            = Styles.Screen_Width,
                    BackgroundColor = Media.colorWhite
                };
            }
            else if (direction == UIDirection.CENTER)
            {
                this.Idle = new UIIdlePage()
                {
                    Float           = Float.TOP_CENTER,
                    Width           = Styles.Width_Page,
                    Top             = Styles.Top_Page,
                    BackgroundColor = Media.colorWhite
                };
            }

            if (height == UIPageHeight.NORMAL)
            {
                this.Idle.Height = Styles.Height_Page;
            }
            else if (height == UIPageHeight.TALL)
            {
                this.Idle.Height = Styles.Height_Page_With_Nav_Bar;
            }

            this.States     = GenerateStates();
            this.Components = GenerateComponents();
        }
Exemplo n.º 7
0
    public SelectableUI GetUIInDirection(UIDirection direction)
    {
        switch (direction)
        {
        case UIDirection.North:

            return(northSelectableUI);

        case UIDirection.South:

            return(southSelectableUI);

        case UIDirection.East:

            return(eastSelectableUI);

        case UIDirection.West:

            return(westSelectableUI);
        }
        return(null);
    }
Exemplo n.º 8
0
    private bool IsScrollActive(UIDirection direction)
    {
        if (!this.gameObject.activeSelf)
        {
            return(false);
        }
        switch (direction)
        {
        case UIDirection.Up:
            if (Input.GetAxisRaw("Vertical") < Minimum_Axis_Threshold)
            {
                return(false);
            }
            return(true);

        case UIDirection.Down:
            if (Input.GetAxisRaw("Vertical") > -Minimum_Axis_Threshold)
            {
                return(false);
            }
            return(true);

        case UIDirection.Right:
            if (Input.GetAxisRaw("Horizontal") < Minimum_Axis_Threshold)
            {
                return(false);
            }
            return(true);

        case UIDirection.Left:
            if (Input.GetAxisRaw("Horizontal") > -Minimum_Axis_Threshold)
            {
                return(false);
            }
            return(true);
        }
        return(false);
    }
Exemplo n.º 9
0
 public pageAbout_4(UIDirection direction, UIPageHeight height) : base(direction, height)
 {
 }
Exemplo n.º 10
0
 public pageMain(UIDirection direction, UIPageHeight height) : base(direction, height)
 {
 }
Exemplo n.º 11
0
 public pageProfile(UIDirection direction, UIPageHeight height) : base(direction, height)
 {
 }
 public pageSoundtracks(UIDirection direction, UIPageHeight height) : base(direction, height)
 {
 }
Exemplo n.º 13
0
 public void EnableSide(UIDirection _direction)
 {
     enabledSides |= _direction;
 }
Exemplo n.º 14
0
 public bool IsEnabled(UIDirection _direction)
 {
     return(enabledSides.HasFlag(_direction));
 }
Exemplo n.º 15
0
 public pageError(UIDirection direction, UIPageHeight height) : base(direction, height)
 {
 }
Exemplo n.º 16
0
 public pageFriends(UIDirection direction, UIPageHeight height) : base(direction, height)
 {
 }
Exemplo n.º 17
0
 public pageLogout(UIDirection direction, UIPageHeight height) : base(direction, height)
 {
 }
        public static bool ButtonIcon(ref Rect rect, Texture2D icon, string tooltip = null, Texture2D iconAddon   = null,
                                      Direction8Way addonLocation = Direction8Way.NorthEast, Color?mouseOverColor = null,
                                      Color?baseColor             = null, int gapSize = SmallMargin, UIDirection direction = UIDirection.LeftThenDown)
        {
            if (Mouse.IsOver(rect))
            {
                GUI.color = mouseOverColor ?? GenUI.MouseoverColor;
            }
            else
            {
                GUI.color = baseColor ?? Color.white;
            }

            GUI.DrawTexture(rect, icon);
            if (iconAddon != null)
            {
                GUI.DrawTexture(AddonRect(rect, addonLocation), iconAddon);
            }
            if (!tooltip.NullOrEmpty())
            {
                TooltipHandler.TipRegion(rect, tooltip);
            }

            var clicked = Widgets.ButtonInvisible(rect);

            switch (direction)
            {
            case UIDirection.LeftThenDown:
            case UIDirection.LeftThenUp:
                rect.x -= rect.width + gapSize;
                break;

            case UIDirection.RightThenDown:
            case UIDirection.RightThenUp:
                rect.x += rect.width + gapSize;
                break;
            }
            return(clicked);
        }
Exemplo n.º 19
0
 public WidgetRow(float x, float y, UIDirection growDirection = UIDirection.RightThenUp, float maxWidth = 99999f, float gap = 4f)
 {
     Init(x, y, growDirection, maxWidth, gap);
 }
Exemplo n.º 20
0
        public virtual Rect OnGUI(Rect _rect)
        {
            Reload(_rect);
            Event evt = Event.current;

            switch (evt.type)
            {
            case EventType.Repaint:
                if (IsEnabled(UIDirection.Top))
                {
                    EditorGUIUtility.AddCursorRect(Sides[UIDirection.Top], MouseCursor.ResizeVertical);
                }
                if (IsEnabled(UIDirection.Bottom))
                {
                    EditorGUIUtility.AddCursorRect(Sides[UIDirection.Bottom], MouseCursor.ResizeVertical);
                }

                if (IsEnabled(UIDirection.Left))
                {
                    EditorGUIUtility.AddCursorRect(Sides[UIDirection.Left], MouseCursor.ResizeHorizontal);
                }
                if (IsEnabled(UIDirection.Right))
                {
                    EditorGUIUtility.AddCursorRect(Sides[UIDirection.Right], MouseCursor.ResizeHorizontal);
                }

                if (IsEnabled(UIDirection.TopLeft))
                {
                    EditorGUIUtility.AddCursorRect(Sides[UIDirection.TopLeft], MouseCursor.ResizeUpLeft);
                }
                if (IsEnabled(UIDirection.TopRight))
                {
                    EditorGUIUtility.AddCursorRect(Sides[UIDirection.TopRight], MouseCursor.ResizeUpRight);
                }

                if (IsEnabled(UIDirection.BottomLeft))
                {
                    EditorGUIUtility.AddCursorRect(Sides[UIDirection.BottomLeft], MouseCursor.ResizeUpRight);
                }
                if (IsEnabled(UIDirection.BottomRight))
                {
                    EditorGUIUtility.AddCursorRect(Sides[UIDirection.BottomRight], MouseCursor.ResizeUpLeft);
                }

                if (IsEnabled(UIDirection.MiddleCenter) && isDragging && sideDirection == UIDirection.MiddleCenter)
                {
                    EditorGUIUtility.AddCursorRect(Sides[UIDirection.MiddleCenter], MouseCursor.MoveArrow);
                }
                break;

            case EventType.MouseDown:
                foreach (var direction in Directions)
                {
                    if (IsEnabled(direction) && Sides[direction].Contains(evt.mousePosition))
                    {
                        sideDirection = direction;
                        isDragging    = true;
                        Event.current.Use();
                        break;
                    }
                }
                break;

            case EventType.MouseUp:
                isDragging    = false;
                sideDirection = UIDirection.None;
                break;

            case EventType.MouseDrag:
                if (isDragging)
                {
                    switch (sideDirection)
                    {
                    case UIDirection.Top:
                        if (IsEnabled(sideDirection))
                        {
                            _rect.y      += evt.delta.y;
                            _rect.height -= evt.delta.y;
                        }
                        break;

                    case UIDirection.Bottom:
                        if (IsEnabled(sideDirection))
                        {
                            _rect.height += evt.delta.y;
                        }
                        break;

                    case UIDirection.Left:
                        if (IsEnabled(sideDirection))
                        {
                            _rect.x     += evt.delta.x;
                            _rect.width -= evt.delta.x;
                        }
                        break;

                    case UIDirection.Right:
                        if (IsEnabled(sideDirection))
                        {
                            _rect.width += evt.delta.x;
                        }
                        break;

                    case UIDirection.TopLeft:
                        if (IsEnabled(sideDirection))
                        {
                            _rect.y      += evt.delta.y;
                            _rect.height -= evt.delta.y;

                            _rect.x     += evt.delta.x;
                            _rect.width -= evt.delta.x;
                        }
                        break;

                    case UIDirection.TopRight:
                        if (IsEnabled(sideDirection))
                        {
                            _rect.y      += evt.delta.y;
                            _rect.height -= evt.delta.y;

                            _rect.width += evt.delta.x;
                        }
                        break;

                    case UIDirection.BottomLeft:
                        if (IsEnabled(sideDirection))
                        {
                            _rect.height += evt.delta.y;

                            _rect.x     += evt.delta.x;
                            _rect.width -= evt.delta.x;
                        }
                        break;

                    case UIDirection.BottomRight:
                        if (IsEnabled(sideDirection))
                        {
                            _rect.height += evt.delta.y;

                            _rect.width += evt.delta.x;
                        }
                        break;

                    case UIDirection.MiddleCenter:
                        if (IsEnabled(sideDirection))
                        {
                            _rect.position += evt.delta;
                        }
                        break;
                    }
                    evt.Use();
                }
                break;

            default:
                break;
            }

            _rect.width  = Mathf.Max(_rect.width, minSize.x);
            _rect.height = Mathf.Max(_rect.height, minSize.y);

            if (maxSize != Vector2.zero)
            {
                _rect.width  = Mathf.Min(_rect.width, maxSize.x);
                _rect.height = Mathf.Min(_rect.height, maxSize.y);
            }

            return(_rect);
        }
Exemplo n.º 21
0
 public pageInbox(UIDirection direction, UIPageHeight height) : base(direction, height)
 {
 }
 public pageCharacters(UIDirection direction, UIPageHeight height) : base(direction, height)
 {
 }