Beispiel #1
0
    /* GFX47 MOD END */

    #endregion



    public static Rect EaseRect(Rect start, Rect end, EasingCurves.EaseType inType, float t)
    {
        EasingFunction ease = GetEasingFunction(inType);

        return(new Rect(
                   ease(start.xMin, end.xMin, t),
                   ease(start.yMin, end.yMin, t),
                   ease(start.width, end.width, t),
                   ease(start.height, end.height, t)));
    }
Beispiel #2
0
    public static Rect EaseRect(string id, Rect start, Rect end, EasingCurves.EaseType inType)
    {
        EasingRect rect;

        if (!easingRects.TryGetValue(id, out rect))
        {
            rect            = new EasingRect();
            rect.start      = start;
            rect.end        = end;
            rect.easeType   = inType;
            rect.t          = 0f;
            rect.ease       = true;
            easingRects[id] = rect;
        }

        if (rect.ease)
        {
            if (rect.t < 1)
            {
                //CurrentDragObject.t += GUIDeltaTime.deltaTimeGUI / CurrentDragObject.TimeFactor;
                rect.t += Time.deltaTime / rect.timeFactor;
            }
            //#endif
            rect.t = Mathf.Clamp01(rect.t);

            // calculate the Rectangle for parameter
            rect.current = EasingCurves.EaseRect(
                rect.start,
                rect.end,
                rect.easeType,
                rect.t);

            // dragObject reached its targetPosition?
            if (rect.t == 1)
            {
                rect.ease = false;
                rect.t    = 0;
            }
        }

        easingRects[id] = rect;
        return(rect.current);
    }
Beispiel #3
0
 public static Rect BeginSideBar(string sidebarName, SidebarType sidebarType, Rect openRect, bool startStateOpen, float inset, EasingCurves.EaseType easeInType, EasingCurves.EaseType easeOutType, float factor)
 {
     return(BeginSideBar(sidebarName, sidebarType, new Rect(), openRect, startStateOpen, inset, easeInType, easeInType, factor));
 }
Beispiel #4
0
    public static Rect BeginSideBar(string sidebarName, SidebarType sidebarType, Rect boundingRect, Rect openRect, bool startStateOpen, float inset, EasingCurves.EaseType easeInType, EasingCurves.EaseType easeOutType, float factor)
    {
        SidebarProperties sidebarProperties = null;

        // If the Sidebar has not been created yet --> create the Sidebar
        if (!sidebars.ContainsKey(sidebarName))
        {
            // create properties instance
            sidebarProperties              = new SidebarProperties();
            sidebarProperties.sidebarName  = sidebarName;
            sidebarProperties.sidebarType  = sidebarType;
            sidebarProperties.inset        = inset;
            sidebarProperties.easeInType   = easeInType;
            sidebarProperties.easeOutType  = easeOutType;
            sidebarProperties.factor       = factor;
            sidebarProperties.boundingRect = boundingRect;


            if (sidebarProperties.boundingRect.Equals(new Rect()))
            {
                sidebarProperties.boundingRect = new Rect(0f, 0f, Screen.width, Screen.height);
            }

            // initialize the Rectangles
            switch (sidebarType)
            {
            case SidebarType.LEFT:
                sidebarProperties.openRect   = new Rect(sidebarProperties.boundingRect.xMin, sidebarProperties.boundingRect.yMin + openRect.yMin, openRect.width, openRect.height);
                sidebarProperties.closedRect = new Rect(sidebarProperties.boundingRect.xMin, sidebarProperties.boundingRect.yMin + openRect.yMin, 0f, openRect.height);
                break;

            case SidebarType.RIGHT:
                sidebarProperties.openRect   = new Rect(sidebarProperties.boundingRect.xMax - openRect.width, sidebarProperties.boundingRect.yMin + openRect.yMin, openRect.width, openRect.height);
                sidebarProperties.closedRect = new Rect(sidebarProperties.boundingRect.xMax, sidebarProperties.boundingRect.yMin + openRect.yMin, 0f, openRect.height);
                break;

            case SidebarType.TOP:
                sidebarProperties.openRect   = new Rect(sidebarProperties.boundingRect.xMin + openRect.xMin, sidebarProperties.boundingRect.yMin, openRect.width, openRect.height);
                sidebarProperties.closedRect = new Rect(sidebarProperties.boundingRect.xMin + openRect.xMin, sidebarProperties.boundingRect.yMin, openRect.width, 0f);
                break;

            case SidebarType.BOTTOM:
                sidebarProperties.openRect   = new Rect(sidebarProperties.boundingRect.xMin + openRect.xMin, sidebarProperties.boundingRect.yMax - openRect.height, openRect.width, openRect.height);
                sidebarProperties.closedRect = new Rect(sidebarProperties.boundingRect.xMin + openRect.xMin, sidebarProperties.boundingRect.yMax, openRect.width, 0f);
                break;

            default:
                break;
            }

            // Initialize withe the desired state after creation
            if (startStateOpen)
            {
                sidebarProperties.currentRect = sidebarProperties.openRect;
                sidebarProperties.open        = 1f;
                sidebarProperties.current     = 1f;
                sidebarProperties.target      = 0f;
            }
            else
            {
                sidebarProperties.currentRect = sidebarProperties.closedRect;
                sidebarProperties.open        = 0f;
                sidebarProperties.current     = 0f;
                sidebarProperties.target      = 1f;
            }

            // Add SidebarProperties to the Dictionary
            sidebars.Add(sidebarName, sidebarProperties);
        }
        else
        {
            // A sidebar of that name already existed --> get its Properties
            sidebars.TryGetValue(sidebarName, out sidebarProperties);


            //// initialize the Rectangles
            switch (sidebarProperties.sidebarType)
            {
            case SidebarType.LEFT:
                sidebarProperties.openRect   = new Rect(sidebarProperties.boundingRect.xMin, sidebarProperties.boundingRect.yMin + openRect.yMin, openRect.width, openRect.height);
                sidebarProperties.closedRect = new Rect(sidebarProperties.boundingRect.xMin, sidebarProperties.boundingRect.yMin + openRect.yMin, 0f, openRect.height);
                break;

            case SidebarType.RIGHT:
                sidebarProperties.openRect   = new Rect(sidebarProperties.boundingRect.xMax - openRect.width, sidebarProperties.boundingRect.yMin + openRect.yMin, openRect.width, openRect.height);
                sidebarProperties.closedRect = new Rect(sidebarProperties.boundingRect.xMax, sidebarProperties.boundingRect.yMin + openRect.yMin, 0f, openRect.height);
                break;

            case SidebarType.TOP:
                sidebarProperties.openRect   = new Rect(sidebarProperties.boundingRect.xMin + openRect.xMin, sidebarProperties.boundingRect.yMin, openRect.width, openRect.height);
                sidebarProperties.closedRect = new Rect(sidebarProperties.boundingRect.xMin + openRect.xMin, sidebarProperties.boundingRect.yMin, openRect.width, 0f);
                break;

            case SidebarType.BOTTOM:
                sidebarProperties.openRect   = new Rect(sidebarProperties.boundingRect.xMin + openRect.xMin, sidebarProperties.boundingRect.yMax - openRect.height, openRect.width, openRect.height);
                sidebarProperties.closedRect = new Rect(sidebarProperties.boundingRect.xMin + openRect.xMin, sidebarProperties.boundingRect.yMax, openRect.width, 0f);
                break;

            default:
                break;
            }
        }


        GUIAreas.Add(sidebarProperties.sidebarName, sidebarProperties.currentRect);
        // Draw the current Rectangle
        CustomGUIUtils.DrawFrameBox(sidebarProperties.currentRect, Color.gray, 3f, Color.black);

        // Start GUIArea with Insets and ScrollView
        GUI.BeginGroup(currentRect);
        GUILayout.BeginArea(sidebarProperties.currentRect);
        GUILayout.BeginVertical();
        GUILayout.Space(sidebarProperties.inset);
        GUILayout.BeginHorizontal();
        GUILayout.Space(sidebarProperties.inset);
        sidebarProperties.scrollPosition = GUILayout.BeginScrollView(sidebarProperties.scrollPosition);

        sidebarPropertiesStack.Push(sidebarProperties);
        return(sidebarProperties.currentRect);
    }
Beispiel #5
0
 public static Rect BeginSideBar(string sidebarName, SidebarType sidebarType, Rect boundingRect, Rect openRect, bool startStateOpen, float inset, EasingCurves.EaseType easeInType)
 {
     return(BeginSideBar(sidebarName, sidebarType, boundingRect, openRect, startStateOpen, 5f, easeInType, 1f));
 }