/// <summary> Resets the UIDrawerArrow root to the default position </summary>
        /// <param name="root"> The arrow holder </param>
        /// <param name="closeDirection"> The UIDrawer close direction </param>
        public static void ResetArrowRootPosition(RectTransform root, SimpleSwipe closeDirection)
        {
            root.localScale = Vector3.one;
            root.transform.localPosition = Vector3.zero;

            // ReSharper disable once SwitchStatementMissingSomeCases
            switch (closeDirection)
            {
            case SimpleSwipe.Left:
                root.anchorMin = new Vector2(1f, 0.5f);
                root.anchorMax = new Vector2(1f, 0.5f);
                break;

            case SimpleSwipe.Right:
                root.anchorMin = new Vector2(0f, 0.5f);
                root.anchorMax = new Vector2(0f, 0.5f);
                break;

            case SimpleSwipe.Up:
                root.anchorMin = new Vector2(0.5f, 0f);
                root.anchorMax = new Vector2(0.5f, 0f);
                break;

            case SimpleSwipe.Down:
                root.anchorMin = new Vector2(0.5f, 1f);
                root.anchorMax = new Vector2(0.5f, 1f);
                break;
            }

            root.pivot            = new Vector2(0.5f, 0.5f);
            root.sizeDelta        = Vector2.zero;
            root.anchoredPosition = Vector2.zero;
        }
        /// <summary> Resets the opened UIDrawerArrow position to its default value </summary>
        /// <param name="opened"> The opened arrow position </param>
        /// <param name="closeDirection"> The UIDrawer close direction </param>
        public static void ResetArrowOpenedPosition(RectTransform opened, SimpleSwipe closeDirection)
        {
            opened.Center(false);
            opened.localPosition = Vector3.zero;

            // ReSharper disable once SwitchStatementMissingSomeCases
            switch (closeDirection)
            {
            case SimpleSwipe.Left:
                opened.anchoredPosition = new Vector2(-50, 0);
                break;

            case SimpleSwipe.Right:
                opened.anchoredPosition = new Vector2(50, 0);
                break;

            case SimpleSwipe.Up:
                opened.anchoredPosition = new Vector2(0, 50);
                break;

            case SimpleSwipe.Down:
                opened.anchoredPosition = new Vector2(0, -50);
                break;
            }
        }
Пример #3
0
 private void Reset()
 {
     CloseDirection = CLOSE_DIRECTION_DEFAULT_VALUE;
     CloseSpeed     = CLOSE_SPEED_DEFAULT_VALUE;
     CustomStartAnchoredPosition = CUSTOM_START_ANCHORED_POSITION_DEFAULT_VALUE;
     DetectGestures = DETECT_GESTURES_DEFAULT_VALUE;
     OpenSpeed      = OPEN_SPEED_DEFAULT_VALUE;
     RenamePrefix   = RENAME_PREFIX_DEFAULT_VALUE;
     RenameSuffix   = RENAME_SUFFIX_DEFAULT_VALUE;
     UseCustomStartAnchoredPosition = USE_CUSTOM_START_ANCHORED_POSITION_DEFAULT_VALUE;
 }
        /// <summary> Returns the UIDrawerArrow.Holder of the UIDrawerArrow's opened and closed positions for the target direction </summary>
        /// <param name="closeDirection"> The UIDrawer close direction </param>
        public Holder GetHolder(SimpleSwipe closeDirection)
        {
            // ReSharper disable once SwitchStatementMissingSomeCases
            switch (closeDirection)
            {
            case SimpleSwipe.Left:  return(Left);

            case SimpleSwipe.Right: return(Right);

            case SimpleSwipe.Up:    return(Up);

            case SimpleSwipe.Down:  return(Down);

            default:                return(null);
            }
        }
Пример #5
0
        /// <summary> Convert a SimpleSwipe into a Swipe </summary>
        /// <param name="simpleSwipe"> Target simple swipe </param>
        /// <param name="reverse"> Should the reversed value be returned? (eg. if SimpleSwipe.Left and reverse is true, it will return Swipe.Right) </param>
        public static Swipe GetSwipe(SimpleSwipe simpleSwipe, bool reverse = false)
        {
            switch (simpleSwipe)
            {
            case SimpleSwipe.None:  return(Swipe.None);

            case SimpleSwipe.Left:  return(reverse ? Swipe.Right : Swipe.Left);

            case SimpleSwipe.Right: return(reverse ? Swipe.Left : Swipe.Right);

            case SimpleSwipe.Up:    return(reverse ? Swipe.Down : Swipe.Up);

            case SimpleSwipe.Down:  return(reverse ? Swipe.Up : Swipe.Down);

            default:                return(Swipe.None);
            }
        }
        /// <summary> Resets the UIDrawerArrow root to the default position </summary>
        /// <param name="closeDirection"> The UIDrawer close direction </param>
        public void ResetArrowRootPosition(SimpleSwipe closeDirection)
        {
            // ReSharper disable once SwitchStatementMissingSomeCases
            switch (closeDirection)
            {
            case SimpleSwipe.Left:
                ResetArrowRootPosition(Left.Root, closeDirection);
                break;

            case SimpleSwipe.Right:
                ResetArrowRootPosition(Right.Root, closeDirection);
                break;

            case SimpleSwipe.Up:
                ResetArrowRootPosition(Up.Root, closeDirection);
                break;

            case SimpleSwipe.Down:
                ResetArrowRootPosition(Down.Root, closeDirection);
                break;
            }
        }