Example #1
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);
    }
Example #2
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));
 }
Example #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));
 }
Example #4
0
 public static Rect BeginSideBar(string sidebarName, SidebarType sidebarType, Rect openRect, bool startStateOpen, float inset)
 {
     return(BeginSideBar(sidebarName, sidebarType, new Rect(), openRect, startStateOpen, 5f, EasingCurves.EaseType.none, 1f));
 }