Esempio n. 1
0
        public static void OnGUI_OSCSessionData_Inspector(UniOSCSessionFileObj obj, float screenWidth, float screenHeight)
        {
            EditorGUILayout.BeginVertical(GUILayout.MaxHeight(screenHeight));

            #region Path

            EditorGUILayout.BeginHorizontal();
            GUIContent guic = new GUIContent("Path: " + AssetDatabase.GUIDToAssetPath(obj.my_guid) + "  .", "");
            Rect       area = GUILayoutUtility.GetRect(guic, GUIStyle.none, GUILayout.MinHeight(30f));
            GUILayout.FlexibleSpace();
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            GUI.Label(area, guic);
            if (UniOSCUtils.IsMouseUpInArea(area))
            {
                UniOSCUtils.SelectObjectInHierachyFromGUID(obj.my_guid);
            }
            _StartDrag(area, obj);
            EditorGUILayout.EndHorizontal();

            #endregion Path

            _OnGUI_DrawButtons(obj, false);

            #region ScrollView

            obj.scrollposInspector = EditorGUILayout.BeginScrollView(obj.scrollposInspector, GUILayout.ExpandHeight(true), GUILayout.Width(screenWidth));            //GUILayout.Width (100)

            EditorGUILayout.BeginHorizontal();
            //Hardcoding layout for wrapping
            maxCols = (int)Math.Max(minCols, Math.Floor((screenWidth - 20f) / (UniOSCSessionItem.MAXWIDTH * 1.0f)));          //Floor Ceiling
            for (var i = 0; i < obj.oscSessionItemList.Count; i++)
            {
                // Begin new row?
                if (i % maxCols == 0 && i > 0)
                {
                    GUILayout.EndHorizontal();
                    GUILayout.BeginHorizontal();
                }
                UniOSCSessionItem c = obj.oscSessionItemList[i];

                UniOSCSessionItemEditor.OnGUI_Inspector(c);
            }            //for

            EditorGUILayout.EndHorizontal();

            EditorGUILayout.EndScrollView();
            #endregion ScrollView


            EditorGUILayout.EndVertical();
        }
Esempio n. 2
0
        //
        public static void OnGUI_OSCSessionData_Editor(UniOSCSessionFileObj obj, float screenWidth, float screenHeight)
        {
            EditorGUILayout.BeginVertical(GUILayout.MaxHeight(screenHeight));

            #region Path
            EditorGUILayout.BeginHorizontal();
            GUIContent guic = new GUIContent("Path: " + AssetDatabase.GUIDToAssetPath(obj.my_guid) + "  .", "");
            Rect       area = GUILayoutUtility.GetRect(guic, GUIStyle.none, GUILayout.MinHeight(30f));     //GUILayout.MaxWidth(400f),
            GUILayout.FlexibleSpace();
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            GUI.Label(area, guic);
            if (UniOSCUtils.IsMouseUpInArea(area))
            {
                UniOSCUtils.SelectObjectInHierachyFromGUID(obj.my_guid);
            }
            _StartDrag(area, obj);
            EditorGUILayout.EndHorizontal();
            #endregion Path

            #region Button
            _OnGUI_DrawButtons(obj, true);
            #endregion Button

            #region Header
            EditorGUILayout.BeginHorizontal();

            GUIContent con0  = new GUIContent("OSC Address ");
            Rect       rect0 = GUILayoutUtility.GetRect(con0, GUI.skin.label, GUILayout.MaxWidth(300f));
            GUI.Label(rect0, con0);

            GUIContent con1  = new GUIContent("");           //Learn
            Rect       rect1 = GUILayoutUtility.GetRect(con1, GUI.skin.toggle, GUILayout.Width(80f));
            GUI.Label(rect1, con1);

            GUIContent con2  = new GUIContent("");           //Delete
            Rect       rect2 = GUILayoutUtility.GetRect(con2, GUI.skin.label, GUILayout.Width(70f));
            GUI.Label(rect2, con2);

            GUIContent con3  = new GUIContent("Data[0]");
            Rect       rect3 = GUILayoutUtility.GetRect(con3, GUI.skin.label, GUILayout.MaxWidth(50f));
            GUI.Label(rect3, con3);

            GUIContent con4  = new GUIContent("Data[1]");
            Rect       rect4 = GUILayoutUtility.GetRect(con4, GUI.skin.label, GUILayout.MaxWidth(50f));
            GUI.Label(rect4, con4);

            GUIContent con5  = new GUIContent("Data[2]");
            Rect       rect5 = GUILayoutUtility.GetRect(con5, GUI.skin.label, GUILayout.MaxWidth(50f));
            GUI.Label(rect5, con5);

            GUIContent con6  = new GUIContent("Data[3]");
            Rect       rect6 = GUILayoutUtility.GetRect(con6, GUI.skin.label, GUILayout.MaxWidth(50f));
            GUI.Label(rect6, con6);

            if (Event.current.type == EventType.Repaint)
            {
                UniOSCUtils.SESSIONLISTLABELRECTS[0] = rect0;
                UniOSCUtils.SESSIONLISTLABELRECTS[1] = rect1;
                UniOSCUtils.SESSIONLISTLABELRECTS[2] = rect2;
                UniOSCUtils.SESSIONLISTLABELRECTS[3] = rect3;
                UniOSCUtils.SESSIONLISTLABELRECTS[4] = rect4;
                UniOSCUtils.SESSIONLISTLABELRECTS[5] = rect5;
                UniOSCUtils.SESSIONLISTLABELRECTS[6] = rect6;
            }

            EditorGUILayout.EndHorizontal();
            #endregion Header


            #region List

            style = new GUIStyle(GUI.skin.box);
            style.normal.background = _tex;
            style.margin            = new RectOffset(0, 0, 0, 2);

            //draw the session items
            EditorGUILayout.BeginHorizontal();

            if (Event.current.type == EventType.Repaint)
            {
                screenWidth = UniOSCUtils.SESSIONLISTHEADERLABELWIDTH;
            }

            obj.scrollpos = EditorGUILayout.BeginScrollView(obj.scrollpos, GUILayout.ExpandHeight(true), GUILayout.Width(screenWidth), GUILayout.MaxWidth(UniOSCUtils.SESSIONLISTHEADERLABELWIDTH));
            int rowIndex = 0;

            try{
                for (var i = 0; i < obj.oscSessionItemList.Count; i++)
                {
                    GUI.backgroundColor = rowIndex % 2 == 0  ?  UniOSCUtils.ITEM_LIST_COLOR_A : UniOSCUtils.ITEM_LIST_COLOR_B;
                    UniOSCSessionItem c = obj.oscSessionItemList[i];

                    GUILayout.BeginHorizontal(style);
                    UniOSCSessionItemEditor.OnGUI_Editor(c);
                    GUILayout.EndHorizontal();

                    rowIndex++;
                }
            }catch (Exception) {
                //drag&drop Exception handling
            }

            GUI.backgroundColor = Color.white;
            EditorGUILayout.EndScrollView();

            EditorGUILayout.EndHorizontal();


            #endregion List

            EditorGUILayout.EndVertical();
        }