Exemplo n.º 1
0
        //-----------------------------------------------------------------------------------
        public void RenderFieldObjects(GUIContent labelContent, CNFieldController fieldController, bool enabled, bool showScope, CNFieldWindow.Type windowType)
        {
            if (objects_rect_width == 1)
            {
                CarManagerEditor.RepaintIfOpen();
            }

            EditorGUI.BeginDisabledGroup(!enabled);
            EditorGUILayout.BeginHorizontal();

            EditorGUILayout.LabelField(labelContent, GUILayout.MaxWidth(showScope ? short_label_width : EditorGUIUtility.labelWidth - 4f));
            DrawObjectsFields(labelContent.text, fieldController, enabled, showScope, windowType);
            EditorGUILayout.EndHorizontal();
            EditorGUI.EndDisabledGroup();
        }
Exemplo n.º 2
0
        //-----------------------------------------------------------------------------------
        private void DrawObjectsFields(string labelText, CNFieldController fieldController, bool enabled, bool showScope, CNFieldWindow.Type windowType)
        {
            GUILayout.Label("", EditorStyles.objectField);
            Rect objectsRect = GUILayoutUtility.GetLastRect();

            Event     ev     = Event.current;
            EventType evType = ev.type;

            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);
        }