示例#1
0
    private void DrawProjectProperties()
    {
        EditorGUILayout.HelpBox("The properties you set up here will be available to all actions of the current project.", MessageType.None, true);

        EditorGUI.BeginChangeCheck();

        var properties = UTomate.ProjectProperties;

        projectPropertyEditorState = DrawPropertyEditor(properties.Properties(), projectPropertyEditorState,
                                                        properties.AddProperty, properties.PropertyExists, properties.DeleteProperty, properties);

        if (EditorGUI.EndChangeCheck())
        {
            EditorUtility.SetDirty(properties);
        }
    }
    private PropertyEditorState DrawPropertyEditor(IEnumerable<UTConfigurableProperty> properties, PropertyEditorState state,
		DoAdd doAdd, PropertyExists propertyExists, DoDelete doDelete, UObject undoTarget)
    {
        EditorGUILayout.BeginVertical ();

        EditorGUILayout.BeginHorizontal ();

        state.newPropertyName = EditorGUILayout.TextField ("Name", state.newPropertyName);
        GUI.enabled = !string.IsNullOrEmpty (state.newPropertyName) && UTContext.IsValidPropertyName (state.newPropertyName) && !propertyExists (state.newPropertyName);
        if (GUILayout.Button ("Add", UTEditorResources.ExpressionButtonStyle)) {
            if (undoTarget != null) {
                CUUndoUtility.RegisterUndo (undoTarget, "Add Property");
            }
            doAdd (state.newPropertyName);
            state.newPropertyName = "";
        }

        GUI.enabled = true;
        EditorGUILayout.EndHorizontal ();
        EditorGUILayout.Space ();
        scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition);
        var index = 0;
        foreach (var property in properties) {
            EditorGUILayout.BeginVertical();
            EditorGUILayout.BeginHorizontal ();

            if (!property.UseExpression) {
                if (property.IsPrivate) {
                    property.Value = EditorGUILayout.PasswordField (property.Name, property.Value);
                } else {
                    property.Value = EditorGUILayout.TextField (property.Name, property.Value);
                }
                if (property.SupportsPrivate) {
                    if (GUILayout.Button (property.IsPrivate ? UTEditorResources.PrivateIcon : UTEditorResources.PublicIcon, UTEditorResources.DeleteButtonStyle)) {
                        property.IsPrivate = !property.IsPrivate;
                        GUIUtility.keyboardControl = 0; // make textfield update.
                    }
                }
            } else {
                property.Expression = EditorGUILayout.TextField (property.Name, property.Expression);
            }

            if (GUILayout.Button (UTEditorResources.DeleteIcon, UTEditorResources.DeleteButtonStyle)) {
                if (undoTarget != null) {
                    CUUndoUtility.RegisterUndo (undoTarget, "Remove property");
                }
                doDelete (property);
                GUIUtility.ExitGUI ();
            }

            var oldExpression = property.UseExpression;
            property.UseExpression = GUILayout.Toggle (oldExpression, UTEditorResources.ExpressionButton, UTEditorResources.ExpressionButtonStyle);

            if (oldExpression != property.UseExpression) {
                GUIUtility.keyboardControl = 0; // make textfield update.
            }

            EditorGUILayout.EndHorizontal ();

            if (!property.UseExpression && property.Value.Contains ("$")) {
                EditorGUILayout.HelpBox (UTEditorResources.VariableWarningText, MessageType.Warning);
            }
            EditorGUILayout.EndVertical();
            index++;
        }
        EditorGUILayout.EndScrollView();
        EditorGUILayout.EndVertical ();
        return state;
    }
    private void DrawProjectProperties()
    {
        EditorGUILayout.HelpBox ("The properties you set up here will be available to all actions of the current project.", MessageType.None, true);

        EditorGUI.BeginChangeCheck ();

        var properties = UTomate.ProjectProperties;
        projectPropertyEditorState = DrawPropertyEditor (properties.Properties (), projectPropertyEditorState,
            properties.AddProperty, properties.PropertyExists, properties.DeleteProperty, properties);

        if (EditorGUI.EndChangeCheck ()) {
            EditorUtility.SetDirty (properties);
        }
    }
 private void DrawEditorProperties()
 {
     EditorGUILayout.HelpBox ("The properties you set up here will be available to all actions in all projects.", MessageType.None, true);
     editorPropertyEditorState = DrawPropertyEditor (UTEditorProperties.Properties (), editorPropertyEditorState,
         UTEditorProperties.AddProperty, UTEditorProperties.PropertyExists, UTEditorProperties.DeleteProperty, null);
 }
示例#5
0
    private PropertyEditorState DrawPropertyEditor(IEnumerable <UTConfigurableProperty> properties, PropertyEditorState state,
                                                   DoAdd doAdd, PropertyExists propertyExists, DoDelete doDelete, UObject undoTarget)
    {
        EditorGUILayout.BeginVertical();

        EditorGUILayout.BeginHorizontal();

        state.newPropertyName = EditorGUILayout.TextField("Name", state.newPropertyName);
        GUI.enabled           = !string.IsNullOrEmpty(state.newPropertyName) && UTContext.IsValidPropertyName(state.newPropertyName) && !propertyExists(state.newPropertyName);
        if (GUILayout.Button("Add", UTEditorResources.ExpressionButtonStyle))
        {
            if (undoTarget != null)
            {
                CUUndoUtility.RegisterUndo(undoTarget, "Add Property");
            }
            doAdd(state.newPropertyName);
            state.newPropertyName = "";
        }

        GUI.enabled = true;
        EditorGUILayout.EndHorizontal();
        EditorGUILayout.Space();
        scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition);
        var index = 0;

        foreach (var property in properties)
        {
            EditorGUILayout.BeginVertical();
            EditorGUILayout.BeginHorizontal();

            if (!property.UseExpression)
            {
                if (property.IsPrivate)
                {
                    property.Value = EditorGUILayout.PasswordField(property.Name, property.Value);
                }
                else
                {
                    property.Value = EditorGUILayout.TextField(property.Name, property.Value);
                }
                if (property.SupportsPrivate)
                {
                    if (GUILayout.Button(property.IsPrivate ? UTEditorResources.PrivateIcon : UTEditorResources.PublicIcon, UTEditorResources.DeleteButtonStyle))
                    {
                        property.IsPrivate         = !property.IsPrivate;
                        GUIUtility.keyboardControl = 0;                         // make textfield update.
                    }
                }
            }
            else
            {
                property.Expression = EditorGUILayout.TextField(property.Name, property.Expression);
            }

            if (GUILayout.Button(UTEditorResources.DeleteIcon, UTEditorResources.DeleteButtonStyle))
            {
                if (undoTarget != null)
                {
                    CUUndoUtility.RegisterUndo(undoTarget, "Remove property");
                }
                doDelete(property);
                GUIUtility.ExitGUI();
            }

            var oldExpression = property.UseExpression;
            property.UseExpression = GUILayout.Toggle(oldExpression, UTEditorResources.ExpressionButton, UTEditorResources.ExpressionButtonStyle);

            if (oldExpression != property.UseExpression)
            {
                GUIUtility.keyboardControl = 0;                 // make textfield update.
            }

            EditorGUILayout.EndHorizontal();

            if (!property.UseExpression && property.Value.Contains("$"))
            {
                EditorGUILayout.HelpBox(UTEditorResources.VariableWarningText, MessageType.Warning);
            }
            EditorGUILayout.EndVertical();
            index++;
        }
        EditorGUILayout.EndScrollView();
        EditorGUILayout.EndVertical();
        return(state);
    }
示例#6
0
 private void DrawEditorProperties()
 {
     EditorGUILayout.HelpBox("The properties you set up here will be available to all actions in all projects.", MessageType.None, true);
     editorPropertyEditorState = DrawPropertyEditor(UTEditorProperties.Properties(), editorPropertyEditorState,
                                                    UTEditorProperties.AddProperty, UTEditorProperties.PropertyExists, UTEditorProperties.DeleteProperty, null);
 }