コード例 #1
0
        //-----------------------------------------------------------------------------------
        public void RenderFieldObjects(string labelText, CNFieldController fieldController, bool enabled, bool showScope, CNFieldWindow.Type windowType)
        {
            if (objects_rect_width == 1)
            {
                CRManagerEditor.RepaintIfOpen();
            }

            EditorGUI.BeginDisabledGroup(!enabled);
            Event     ev     = Event.current;
            EventType evType = ev.type;

            EditorGUILayout.BeginHorizontal();

            EditorGUILayout.LabelField(labelText, GUILayout.MaxWidth(showScope ? short_label_width : long_label_width));

            GUILayout.Label("", EditorStyles.objectField);
            Rect objectsRect = GUILayoutUtility.GetLastRect();

            if (evType == EventType.Repaint)
            {
                objects_rect_width = objectsRect.width;
            }

            fieldController.DrawFieldItems(objectsRect, tex_icon_size);

            if (evType == EventType.MouseDown && ev.button == 0 &&
                objectsRect.Contains(ev.mousePosition))
            {
                if (windowType == CNFieldWindow.Type.normal)
                {
                    CNFieldWindowSmall.ShowWindow <CNFieldWindowSmall>(labelText, fieldController, this);
                }
                else if (windowType == CNFieldWindow.Type.extended)
                {
                    CNFieldWindowBig.ShowWindow <CNFieldWindowBig>(labelText, fieldController, this);
                }
            }
            if (showScope)
            {
                GUILayout.Space(10f);
                EditorGUILayout.LabelField("Scope", GUILayout.Width(40f));
                CNField.ScopeFlag auxScope = fieldController.GetScopeType();
                EditorGUI.BeginChangeCheck();
                auxScope = (CNField.ScopeFlag)EditorGUILayout.EnumPopup(auxScope, GUILayout.Width(70f));
                if (EditorGUI.EndChangeCheck())
                {
                    fieldController.SetScopeType(auxScope);
                    cnHierarchy.RecalculateFieldsDueToUserAction();
                    EditorUtility.SetDirty(Data);
                }
            }
            ProccesEvents(ev, evType, fieldController, objectsRect);
            EditorGUILayout.EndHorizontal();
            EditorGUI.EndDisabledGroup();
        }
コード例 #2
0
        //-----------------------------------------------------------------------------------
        public override void RenderGUI(Rect area)
        {
            if (ownerNode_ == null)
            {
                CNFieldWindowBig.CloseIfOpen();
                EditorGUIUtility.ExitGUI();
            }

            EditorGUILayout.BeginHorizontal(EditorStyles.toolbar);

            DrawToolStrip();

            EditorGUILayout.EndHorizontal();

            Event ev = Event.current;

            EditorGUI.LabelField(new Rect(5f, 30f, area.width, 20f), "Selected Objects:");

            Rect listAreaObjects = new Rect(5f, 50f, Mathf.Ceil((area.width - 10f) / 2f - 30f), Mathf.Ceil(area.height - botMargin));
            Rect buttonRect      = new Rect(listAreaObjects.xMax + 10f, (listAreaObjects.yMax - listAreaObjects.yMin - buttonsHeight) / 2f + 30f, 40f, 35f);

            Rect listAreaNodes = new Rect(buttonRect.xMax + 10f, listAreaObjects.yMin, (area.width - 10f) / 2f - 30f, area.height - botMargin - buttonsHeight - 10f);
            Rect buttonsArea   = new Rect(buttonRect.xMax + 10f, listAreaNodes.yMax + 2f, listAreaNodes.width, buttonsHeight);

            Rect label1Area = new Rect(buttonRect.xMin + 10f, buttonsArea.yMin + 27f, 20f, 17f);
            Rect label2Area = new Rect(buttonRect.xMin + 10f, label1Area.yMax + 13f, 20f, 17f);

            EditorGUI.BeginDisabledGroup(!Controller.AreGameObjectsAllowed());

            EditorGUI.LabelField(label1Area, "<<");
            EditorGUI.LabelField(label2Area, "<<");

            EditorGUI.EndDisabledGroup();

            ProcessEvents(ev, listAreaObjects, listAreaNodes);

            EditorGUI.BeginDisabledGroup(!nodesController_.AnyNodeSelected);
            if (GUI.Button(buttonRect, "<<"))
            {
                nodesController_.AddSelectedNodes();
            }
            EditorGUI.EndDisabledGroup();
            EditorGUI.LabelField(new Rect(buttonRect.xMax + 10f, 30f, area.width, 20f), "Selectable Nodes:");

            selectionListBox_.RenderGUI(listAreaObjects);
            nodesListBox_.RenderGUI(listAreaNodes);

            GUILayout.BeginArea(buttonsArea);

            EditorGUI.BeginChangeCheck();

            bool isShowOwnerGroupOnly = field_.ShowOwnerGroupOnly;

            GUIStyle styleToggle = new GUIStyle(EditorStyles.label);

            if (isShowOwnerGroupOnly)
            {
                styleToggle.fontStyle = FontStyle.Bold;
            }

            field_.ShowOwnerGroupOnly = EditorGUILayout.ToggleLeft("Show only owner group", isShowOwnerGroupOnly, styleToggle);
            if (EditorGUI.EndChangeCheck())
            {
                nodesController_.SetSelectableNodes();
                EditorUtility.SetDirty(ownerNode_);
            }

            EditorGUILayout.Space();

            EditorGUI.BeginDisabledGroup(!Controller.AreGameObjectsAllowed());
            if (GUILayout.Button("Name Selector"))
            {
                Controller.AddNameSelectorWindow();
            }

            EditorGUILayout.Space();

            if (GUILayout.Button("Game Object Selection"))
            {
                Controller.AddCurrentSelection();
            }
            EditorGUI.EndDisabledGroup();

            GUILayout.EndArea();
        }