public void Render(UTFieldWrapper wrapper)
 {
     if (!wrapper.InspectorHint.multiSelect)
     {
         if (wrapper.Label != null)
         {
             wrapper.Value = EditorGUILayout.EnumPopup(wrapper.Label, (Enum)wrapper.Value);
         }
         else
         {
             wrapper.Value = EditorGUILayout.EnumPopup((Enum)wrapper.Value);
         }
     }
     else
     {
         if (wrapper.Label != null)
         {
             wrapper.Value = EditorGUILayout.EnumMaskField(wrapper.Label, (Enum)wrapper.Value);
         }
         else
         {
             wrapper.Value = EditorGUILayout.EnumMaskField((Enum)wrapper.Value);
         }
     }
 }
Exemple #2
0
    public void Render(UTFieldWrapper wrapper)
    {
        var hint = wrapper.InspectorHint;

        if (wrapper.Label != null)
        {
            if (hint.displayAs == UTInspectorHint.DisplayAs.Slider)
            {
                wrapper.Value = EditorGUILayout.IntSlider(wrapper.Label, (int)wrapper.Value, (int)hint.minValue, (int)hint.maxValue);
            }
            else
            {
                wrapper.Value = EditorGUILayout.IntField(wrapper.Label, (int)wrapper.Value);
            }
        }
        else
        {
            if (hint.displayAs == UTInspectorHint.DisplayAs.Slider)
            {
                wrapper.Value = EditorGUILayout.IntSlider((int)wrapper.Value, (int)hint.minValue, (int)hint.maxValue);
            }
            else
            {
                wrapper.Value = EditorGUILayout.IntField((int)wrapper.Value);
            }
        }
    }
    public void Render(UTFieldWrapper fieldWrapper)
    {
        EditorGUILayout.BeginHorizontal();
        if (fieldWrapper.Label != null)
        {
            EditorGUILayout.PrefixLabel(fieldWrapper.Label);
        }
        else
        {
            EditorGUILayout.PrefixLabel(" ");
        }

        Quaternion val = (Quaternion)fieldWrapper.Value;

        GUILayout.Label("X");
        val.x = EditorGUILayout.FloatField(val.x);
        GUILayout.Label("Y");
        val.y = EditorGUILayout.FloatField(val.y);
        GUILayout.Label("Z");
        val.z = EditorGUILayout.FloatField(val.z);
        GUILayout.Label("W");
        val.w = EditorGUILayout.FloatField(val.w);
        fieldWrapper.Value = val;
        EditorGUILayout.EndHorizontal();
    }
Exemple #4
0
    public void Render(UTFieldWrapper fieldWrapper)
    {
        EditorGUILayout.BeginHorizontal();
        if (fieldWrapper.Label != null)
        {
            EditorGUILayout.PrefixLabel(fieldWrapper.Label);
        }
        else
        {
            EditorGUILayout.PrefixLabel(" ");
        }

        Rect val = (Rect)fieldWrapper.Value;

        GUILayout.Label("X");
        val.x = EditorGUILayout.FloatField(val.x);
        GUILayout.Label("Y");
        val.y = EditorGUILayout.FloatField(val.y);
        GUILayout.Label("W");
        val.width = EditorGUILayout.FloatField(val.width);
        GUILayout.Label("H");
        val.height         = EditorGUILayout.FloatField(val.height);
        fieldWrapper.Value = val;
        EditorGUILayout.EndHorizontal();
    }
    public void Render(UTFieldWrapper fieldWrapper)
    {
        Type baseType = fieldWrapper.InspectorHint.baseType;

        var compatibleTypes = UTComponentScanner.FindCompatibleTypes(baseType);

        var val = (UTTypeInfo) fieldWrapper.Value;
        int currentIndex = -1;
        if (val != null) {
            currentIndex = Array.IndexOf(compatibleTypes.TypeNames, val.TypeName);
        }

        int newIndex = -1;
        if (fieldWrapper.Label != null) {
            newIndex = EditorGUILayout.Popup(fieldWrapper.Label, currentIndex, compatibleTypes.NicifiedTypeNames);
        } else {
            newIndex = EditorGUILayout.Popup(currentIndex, compatibleTypes.NicifiedTypeNames);
        }

        if (currentIndex != newIndex) {
            if (newIndex == -1) {
                fieldWrapper.Value = null;
            } else {
                fieldWrapper.Value = new UTTypeInfo(compatibleTypes.TypeNames[newIndex]);
            }
        }
    }
 public void Render(UTFieldWrapper fieldWrapper)
 {
     if (fieldWrapper.Label != null) {
         fieldWrapper.Value = EditorGUILayout.Toggle (fieldWrapper.Label, (bool)fieldWrapper.Value);
     } else {
         fieldWrapper.Value = EditorGUILayout.Toggle ((bool)fieldWrapper.Value);
     }
 }
 public void Render(UTFieldWrapper fieldWrapper)
 {
     if (fieldWrapper.Label != null) {
         fieldWrapper.Value = EditorGUILayout.LayerField (fieldWrapper.Label, (int)fieldWrapper.Value);
     } else {
         fieldWrapper.Value = EditorGUILayout.LayerField ((int)fieldWrapper.Value);
     }
 }
 public void Render(UTFieldWrapper wrapper)
 {
     if (wrapper.Label != null) {
         wrapper.Value = EditorGUILayout.ColorField (wrapper.Label, (Color)wrapper.Value);
     } else {
         wrapper.Value = EditorGUILayout.ColorField ((Color)wrapper.Value);
     }
 }
 public void Render(UTFieldWrapper fieldWrapper)
 {
     if (fieldWrapper.Label != null) {
         fieldWrapper.Value = EditorGUILayout.TagField (fieldWrapper.Label, (string)fieldWrapper.Value);
     } else {
         fieldWrapper.Value = EditorGUILayout.TagField ((string)fieldWrapper.Value);
     }
 }
    public void Render(UTFieldWrapper fieldWrapper)
    {
        Type baseType        = fieldWrapper.InspectorHint.baseType;
        var  compatibleTypes = UTComponentScanner.FindCompatibleTypes(baseType);

        var val          = (UTMemberInfo)fieldWrapper.Value;
        int currentIndex = -1;

        if (val != null)
        {
            currentIndex = Array.IndexOf(compatibleTypes.TypeNames, val.TypeName);
        }
        EditorGUILayout.BeginVertical();
        int newIndex = -1;

        if (fieldWrapper.Label != null)
        {
            newIndex = EditorGUILayout.Popup(fieldWrapper.Label, currentIndex, compatibleTypes.NicifiedTypeNames);
        }
        else
        {
            newIndex = EditorGUILayout.Popup(currentIndex, compatibleTypes.NicifiedTypeNames);
        }

        if (currentIndex != newIndex)
        {
            if (newIndex == -1)
            {
                fieldWrapper.Value = null;
                val = null;
            }
            else
            {
                var    type            = UTInternalCall.GetType(compatibleTypes.TypeNames [newIndex]);
                var    writableMembers = UTComponentScanner.FindPublicWritableMembersOf(type);
                string propertyPath    = null;
                if (writableMembers.MemberInfos.Length > 0)
                {
                    propertyPath = writableMembers.MemberInfos[0].Name;
                }
                val = new UTMemberInfo(type.FullName, propertyPath);
                fieldWrapper.Value = val;
            }
        }

        GUI.enabled = val != null && !string.IsNullOrEmpty(val.TypeName);
        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.PrefixLabel(" ");
        if (GUILayout.Button(val.FieldPath, EditorStyles.popup))
        {
            var genericMenu = BuildMenu(val.Type, val.SetFieldPath);
            genericMenu.ShowAsContext();
        }
        EditorGUILayout.EndHorizontal();
        GUI.enabled = true;

        EditorGUILayout.EndVertical();
    }
 public void Render(UTFieldWrapper wrapper)
 {
     if (wrapper.Label != null) {
         // Tooltips for texture2D selectors are borked, just showing the label here...
         wrapper.Value = EditorGUILayout.ObjectField (wrapper.Label.text, (UObject)wrapper.Value, wrapper.AssetType, false);
     } else {
         wrapper.Value = EditorGUILayout.ObjectField ((UObject)wrapper.Value, wrapper.AssetType, false);
     }
 }
Exemple #12
0
 public void Render(UTFieldWrapper fieldWrapper)
 {
     if (fieldWrapper.Label != null)
     {
         fieldWrapper.Value = EditorGUILayout.LayerField(fieldWrapper.Label, (int)fieldWrapper.Value);
     }
     else
     {
         fieldWrapper.Value = EditorGUILayout.LayerField((int)fieldWrapper.Value);
     }
 }
 public void Render(UTFieldWrapper fieldWrapper)
 {
     if (fieldWrapper.Label != null)
     {
         fieldWrapper.Value = EditorGUILayout.Toggle(fieldWrapper.Label, (bool)fieldWrapper.Value);
     }
     else
     {
         fieldWrapper.Value = EditorGUILayout.Toggle((bool)fieldWrapper.Value);
     }
 }
Exemple #14
0
 public void Render(UTFieldWrapper wrapper)
 {
     if (wrapper.Label != null)
     {
         wrapper.Value = EditorGUILayout.ColorField(wrapper.Label, (Color)wrapper.Value);
     }
     else
     {
         wrapper.Value = EditorGUILayout.ColorField((Color)wrapper.Value);
     }
 }
 public void Render(UTFieldWrapper fieldWrapper)
 {
     if (fieldWrapper.Label != null)
     {
         fieldWrapper.Value = EditorGUILayout.TagField(fieldWrapper.Label, (string)fieldWrapper.Value);
     }
     else
     {
         fieldWrapper.Value = EditorGUILayout.TagField((string)fieldWrapper.Value);
     }
 }
    protected virtual bool DrawPropertyArrayMember(UTFieldWrapper fieldWrapper)
    {
        var delete = false;

        if (rendererDelegate == null || !rendererDelegate.DrawArrayMember(fieldWrapper, out delete))
        {
            EditorGUILayout.BeginHorizontal();
            delete = DrawProperty(fieldWrapper, true);
            EditorGUILayout.EndHorizontal();
        }
        return(delete);
    }
Exemple #17
0
 public void Render(UTFieldWrapper wrapper)
 {
     if (wrapper.Label != null)
     {
         // Tooltips for texture2D selectors are borked, just showing the label here...
         wrapper.Value = EditorGUILayout.ObjectField(wrapper.Label.text, (UObject)wrapper.Value, wrapper.AssetType, false);
     }
     else
     {
         wrapper.Value = EditorGUILayout.ObjectField((UObject)wrapper.Value, wrapper.AssetType, false);
     }
 }
    public void Render(UTFieldWrapper wrapper)
    {
        var lineHeight = 20;

        var val = (string)wrapper.Value;
        if (val == null) {
            val = "";
        }

        if (wrapper.Label != null) {
            if (wrapper.InspectorHint.displayAs == UTInspectorHint.DisplayAs.TextArea) {
                EditorGUILayout.BeginVertical ();
                EditorGUILayout.LabelField (wrapper.Label);
                wrapper.Value = EditorGUILayout.TextArea (val, GUILayout.Height(wrapper.InspectorHint.lines * lineHeight));
                EditorGUILayout.EndVertical ();
            } else if (wrapper.InspectorHint.displayAs == UTInspectorHint.DisplayAs.Password) {
                wrapper.Value = EditorGUILayout.PasswordField (wrapper.Label, val);
            } else {
                wrapper.Value = EditorGUILayout.TextField (wrapper.Label, val);
            }
        } else {
            if (wrapper.InspectorHint.displayAs == UTInspectorHint.DisplayAs.TextArea) {
                wrapper.Value = EditorGUILayout.TextArea (val,GUILayout.Height(wrapper.InspectorHint.lines * lineHeight));
            } else if (wrapper.InspectorHint.displayAs == UTInspectorHint.DisplayAs.Password) {
                wrapper.Value = EditorGUILayout.PasswordField (val);
            } else {
                wrapper.Value = EditorGUILayout.TextField (val);
            }
        }
        if (wrapper.InspectorHint.displayAs == UTInspectorHint.DisplayAs.FolderSelect ||
                    wrapper.InspectorHint.displayAs == UTInspectorHint.DisplayAs.SaveFileSelect ||
                    wrapper.InspectorHint.displayAs == UTInspectorHint.DisplayAs.OpenFileSelect) {
            if (GUILayout.Button (UTEditorResources.FolderIcon, UTEditorResources.FolderButtonStyle)) {
                var path = !string.IsNullOrEmpty ((string)wrapper.Value) ? (string)wrapper.Value : UTFileUtils.ProjectRoot;
                var result = "";
                switch (wrapper.InspectorHint.displayAs) {
                case UTInspectorHint.DisplayAs.FolderSelect:
                    result = EditorUtility.OpenFolderPanel (wrapper.InspectorHint.caption, path, "");
                    break;
                case UTInspectorHint.DisplayAs.OpenFileSelect:
                    result = EditorUtility.OpenFilePanel (wrapper.InspectorHint.caption, path, wrapper.InspectorHint.extension);
                    break;
                case UTInspectorHint.DisplayAs.SaveFileSelect:
                    result = EditorUtility.SaveFilePanel (wrapper.InspectorHint.caption, path, "", wrapper.InspectorHint.extension);
                    break;

                }
                if (!string.IsNullOrEmpty (result)) {
                    wrapper.Value = result;
                }
            }
        }
    }
Exemple #19
0
    public UTFieldValidity CheckValidity(UTFieldWrapper wrapper, out string errorMessage)
    {
        if (wrapper.IsString)
        {
            if (!wrapper.SupportsExpressions || !wrapper.UseExpression)
            {
                if (wrapper.InspectorHint.required)
                {
                    if (string.IsNullOrEmpty(wrapper.Value as string))
                    {
                        errorMessage = "This field is required.";
                        return(UTFieldValidity.Invalid);
                    }
                }
            }
            if (wrapper.SupportsExpressions && !wrapper.UseExpression && !wrapper.InspectorHint.containsExpression)
            {
                var match = patternFinder.Match(wrapper.Value as string);
                if (match.Success)
                {
                    errorMessage = "You are using a parameter reference in a plain property. Did you forget to enable expression mode?";
                    return(UTFieldValidity.ValidWithWarning);
                }
            }

            if (wrapper.InspectorHint.displayAs == UTInspectorHint.DisplayAs.Password &&
                wrapper.SupportsExpressions && !wrapper.UseExpression && !string.IsNullOrEmpty(wrapper.Value as string))
            {
                errorMessage = "It is recommended to use Editor Properties to store passwords.";
                return(UTFieldValidity.ValidWithWarning);
            }
        }

        if (wrapper.IsAsset)
        {
            if (!wrapper.SupportsExpressions || !wrapper.UseExpression)
            {
                if (wrapper.InspectorHint.required && wrapper.Value == null)
                {
                    errorMessage = "This field is required.";
                    return(UTFieldValidity.Invalid);
                }
            }
        }
        errorMessage = "";
        return(UTFieldValidity.Valid);
    }
 public void Render(UTFieldWrapper wrapper)
 {
     var hint = wrapper.InspectorHint;
     if (wrapper.Label != null) {
         if (hint.displayAs == UTInspectorHint.DisplayAs.Slider) {
             wrapper.Value = EditorGUILayout.IntSlider (wrapper.Label, (int)wrapper.Value, (int)hint.minValue, (int)hint.maxValue);
         } else {
             wrapper.Value = EditorGUILayout.IntField (wrapper.Label, (int)wrapper.Value);
         }
     } else {
         if (hint.displayAs == UTInspectorHint.DisplayAs.Slider) {
             wrapper.Value = EditorGUILayout.IntSlider ((int)wrapper.Value, (int)hint.minValue, (int)hint.maxValue);
         } else {
             wrapper.Value = EditorGUILayout.IntField ((int)wrapper.Value);
         }
     }
 }
    public void Render(UTFieldWrapper fieldWrapper)
    {
        EditorGUILayout.BeginHorizontal();
        if (fieldWrapper.Label != null) {
            EditorGUILayout.PrefixLabel(fieldWrapper.Label);
        } else {
            EditorGUILayout.PrefixLabel(" ");
        }

        Vector2 val = (Vector2) fieldWrapper.Value;
        GUILayout.Label("X");
        val.x = EditorGUILayout.FloatField(val.x);
        GUILayout.Label("Y");
        val.y = EditorGUILayout.FloatField(val.y);
        fieldWrapper.Value = val;
        EditorGUILayout.EndHorizontal();
    }
    public void Render(UTFieldWrapper wrapper)
    {
        if (!wrapper.InspectorHint.multiSelect) {
            if (wrapper.Label != null) {
                wrapper.Value = EditorGUILayout.EnumPopup (wrapper.Label, (Enum)wrapper.Value);
            } else {
                wrapper.Value = EditorGUILayout.EnumPopup ((Enum)wrapper.Value);
            }
        } else {
            if (wrapper.Label != null) {
                wrapper.Value = EditorGUILayout.EnumMaskField (wrapper.Label, (Enum)wrapper.Value);
            } else {
                wrapper.Value = EditorGUILayout.EnumMaskField ((Enum)wrapper.Value);
            }

        }
    }
    public void Render(UTFieldWrapper fieldWrapper)
    {
        Type baseType = fieldWrapper.InspectorHint.baseType;
        var compatibleTypes = UTComponentScanner.FindCompatibleTypes (baseType);

        var val = (UTMemberInfo)fieldWrapper.Value;
        int currentIndex = -1;
        if (val != null) {
            currentIndex = Array.IndexOf (compatibleTypes.TypeNames, val.TypeName);
        }
        EditorGUILayout.BeginVertical ();
        int newIndex = -1;
        if (fieldWrapper.Label != null) {
            newIndex = EditorGUILayout.Popup (fieldWrapper.Label, currentIndex, compatibleTypes.NicifiedTypeNames);
        } else {
            newIndex = EditorGUILayout.Popup (currentIndex, compatibleTypes.NicifiedTypeNames);
        }

        if (currentIndex != newIndex) {
            if (newIndex == -1) {
                fieldWrapper.Value = null;
                val = null;
            } else {
                var type = UTInternalCall.GetType (compatibleTypes.TypeNames [newIndex]);
                var writableMembers = UTComponentScanner.FindPublicWritableMembersOf(type);
                string propertyPath = null;
                if (writableMembers.MemberInfos.Length > 0) {
                    propertyPath = writableMembers.MemberInfos[0].Name;
                }
                val = new UTMemberInfo (type.FullName, propertyPath);
                fieldWrapper.Value = val;
            }
        }

        GUI.enabled = val != null && !string.IsNullOrEmpty(val.TypeName);
        EditorGUILayout.BeginHorizontal ();
        EditorGUILayout.PrefixLabel (" ");
        if (GUILayout.Button (val.FieldPath, EditorStyles.popup)) {
            var genericMenu = BuildMenu (val.Type, val.SetFieldPath);
            genericMenu.ShowAsContext ();
        }
        EditorGUILayout.EndHorizontal ();
        GUI.enabled = true;

        EditorGUILayout.EndVertical ();
    }
    public override UTFieldValidity CheckValidity(UTFieldWrapper wrapper, out string errorMessage)
    {
        var isValid = base.CheckValidity (wrapper, out errorMessage);
        if (isValid == UTFieldValidity.Valid) {
            // don't overwrite error messages from above.
            if (wrapper.FieldName == "arguments") {
                if (wrapper.UseExpression ? wrapper.Expression.Contains ("\\\"") : (wrapper.Value as String).Contains ("\"")) {
                    errorMessage = "You've typed a quote or quoting expression. Note that all quoting is done automatically by the action, so this might not do what you expect.";
                    return UTFieldValidity.ValidWithWarning;
                }

                if (!wrapper.UseExpression && ((wrapper.Value)as string ).Contains(" ")) {
                    errorMessage = "You've typed a space character in this parameter. Depending on your use case this might be ok, but make sure that you place one parameter per line.";
                    return UTFieldValidity.ValidWithWarning;
                }
            }

        }
        return isValid;
    }
    public void Render(UTFieldWrapper fieldWrapper)
    {
        EditorGUILayout.BeginHorizontal();
        if (fieldWrapper.Label != null) {
            EditorGUILayout.PrefixLabel(fieldWrapper.Label);
        } else {
            EditorGUILayout.PrefixLabel(" ");
        }

        Rect val = (Rect) fieldWrapper.Value;
        GUILayout.Label("X");
        val.x = EditorGUILayout.FloatField(val.x);
        GUILayout.Label("Y");
        val.y = EditorGUILayout.FloatField(val.y);
        GUILayout.Label("W");
        val.width = EditorGUILayout.FloatField(val.width);
        GUILayout.Label("H");
        val.height = EditorGUILayout.FloatField(val.height);
        fieldWrapper.Value = val;
        EditorGUILayout.EndHorizontal();
    }
    public void Render(UTFieldWrapper fieldWrapper)
    {
        EditorGUILayout.BeginHorizontal();
        if (fieldWrapper.Label != null) {
            EditorGUILayout.PrefixLabel(fieldWrapper.Label);
        } else {
            EditorGUILayout.PrefixLabel(" ");
        }

        Quaternion val = (Quaternion) fieldWrapper.Value;
        GUILayout.Label("X");
        val.x = EditorGUILayout.FloatField(val.x);
        GUILayout.Label("Y");
        val.y = EditorGUILayout.FloatField(val.y);
        GUILayout.Label("Z");
        val.z = EditorGUILayout.FloatField(val.z);
        GUILayout.Label("W");
        val.w = EditorGUILayout.FloatField(val.w);
        fieldWrapper.Value = val;
        EditorGUILayout.EndHorizontal();
    }
Exemple #27
0
    public void Render(UTFieldWrapper fieldWrapper)
    {
        EditorGUILayout.BeginHorizontal();
        if (fieldWrapper.Label != null)
        {
            EditorGUILayout.PrefixLabel(fieldWrapper.Label);
        }
        else
        {
            EditorGUILayout.PrefixLabel(" ");
        }

        Vector2 val = (Vector2)fieldWrapper.Value;

        GUILayout.Label("X");
        val.x = EditorGUILayout.FloatField(val.x);
        GUILayout.Label("Y");
        val.y = EditorGUILayout.FloatField(val.y);
        fieldWrapper.Value = val;
        EditorGUILayout.EndHorizontal();
    }
    public UTFieldValidity CheckValidity(UTFieldWrapper wrapper, out string errorMessage)
    {
        if (wrapper.IsString) {
            if (!wrapper.SupportsExpressions || !wrapper.UseExpression) {
                if (wrapper.InspectorHint.required) {
                    if (string.IsNullOrEmpty (wrapper.Value as string)) {
                        errorMessage = "This field is required.";
                        return UTFieldValidity.Invalid;
                    }
                }
            }
            if (wrapper.SupportsExpressions && !wrapper.UseExpression && !wrapper.InspectorHint.containsExpression) {
                var match = patternFinder.Match (wrapper.Value as string);
                if (match.Success) {
                    errorMessage = "You are using a parameter reference in a plain property. Did you forget to enable expression mode?";
                    return UTFieldValidity.ValidWithWarning;
                }
            }

            if (wrapper.InspectorHint.displayAs == UTInspectorHint.DisplayAs.Password &&
                wrapper.SupportsExpressions && !wrapper.UseExpression && !string.IsNullOrEmpty(wrapper.Value as string)) {
                errorMessage = "It is recommended to use Editor Properties to store passwords.";
                return UTFieldValidity.ValidWithWarning;
            }

        }

        if (wrapper.IsAsset) {
            if (!wrapper.SupportsExpressions || !wrapper.UseExpression) {
                if (wrapper.InspectorHint.required && wrapper.Value == null) {
                    errorMessage = "This field is required.";
                    return UTFieldValidity.Invalid;
                }
            }
        }
        errorMessage = "";
        return UTFieldValidity.Valid;
    }
    public void Render(UTFieldWrapper fieldWrapper)
    {
        Type baseType = fieldWrapper.InspectorHint.baseType;

        var compatibleTypes = UTComponentScanner.FindCompatibleTypes(baseType);

        var val          = (UTTypeInfo)fieldWrapper.Value;
        int currentIndex = -1;

        if (val != null)
        {
            currentIndex = Array.IndexOf(compatibleTypes.TypeNames, val.TypeName);
        }

        int newIndex = -1;

        if (fieldWrapper.Label != null)
        {
            newIndex = EditorGUILayout.Popup(fieldWrapper.Label, currentIndex, compatibleTypes.NicifiedTypeNames);
        }
        else
        {
            newIndex = EditorGUILayout.Popup(currentIndex, compatibleTypes.NicifiedTypeNames);
        }

        if (currentIndex != newIndex)
        {
            if (newIndex == -1)
            {
                fieldWrapper.Value = null;
            }
            else
            {
                fieldWrapper.Value = new UTTypeInfo(compatibleTypes.TypeNames[newIndex]);
            }
        }
    }
Exemple #30
0
    public override UTFieldValidity CheckValidity(UTFieldWrapper wrapper, out string errorMessage)
    {
        var isValid = base.CheckValidity(wrapper, out errorMessage);

        if (isValid == UTFieldValidity.Valid)
        {
            // don't overwrite error messages from above.
            if (wrapper.FieldName == "arguments")
            {
                if (wrapper.UseExpression ? wrapper.Expression.Contains("\\\"") : (wrapper.Value as String).Contains("\""))
                {
                    errorMessage = "You've typed a quote or quoting expression. Note that all quoting is done automatically by the action, so this might not do what you expect.";
                    return(UTFieldValidity.ValidWithWarning);
                }

                if (!wrapper.UseExpression && ((wrapper.Value) as string).Contains(" "))
                {
                    errorMessage = "You've typed a space character in this parameter. Depending on your use case this might be ok, but make sure that you place one parameter per line.";
                    return(UTFieldValidity.ValidWithWarning);
                }
            }
        }
        return(isValid);
    }
    protected virtual bool DrawProperty(UTFieldWrapper wrapper, bool removeable)
    {
        string errorMessage = "";
        UTFieldValidity propertyIsValid = fieldValidityChecker == null ? UTFieldValidity.Valid :
            fieldValidityChecker.CheckValidity (wrapper, out errorMessage);
        if (propertyIsValid != UTFieldValidity.Valid) {
            EditorGUILayout.BeginVertical ();
            EditorGUILayout.BeginHorizontal ();
        }

        bool isRenderedByDelegate = rendererDelegate != null && rendererDelegate.DrawProperty (wrapper);
        bool removed = false;
        if (!isRenderedByDelegate) {
            if (wrapper.SupportsExpressions) {
                if (wrapper.UseExpression) {
                    if (wrapper.Label != null) {
                        wrapper.Expression = EditorGUILayout.TextField (wrapper.Label, wrapper.Expression);
                    } else {
                        wrapper.Expression = EditorGUILayout.TextField (wrapper.Expression);
                    }
                }
            }

            if (!wrapper.SupportsExpressions || !wrapper.UseExpression) {
                var fieldType = wrapper.FieldType;
                if (fieldType.IsArray) {
                    fieldType = fieldType.GetElementType();
                }
                var renderer = UTPropertyRendererRegistry.GetRendererForType(fieldType);
                if (renderer != null) {
                    renderer.Render(wrapper);
                }
                else {
                    EditorGUILayout.HelpBox("Missing renderer for property " + wrapper.FieldName + " of type " + fieldType.FullName, MessageType.Warning);
                }
            }
        }
        if (removeable) {
            if (GUILayout.Button (UTEditorResources.DeleteIcon, UTEditorResources.DeleteButtonStyle)) {
                removed = true;
            }
        }
        if (!isRenderedByDelegate) {
            if (wrapper.SupportsExpressions) {
                var oldExpression = wrapper.UseExpression;
                wrapper.UseExpression = GUILayout.Toggle (oldExpression, UTEditorResources.ExpressionButton, UTEditorResources.ExpressionButtonStyle);
                if (oldExpression != wrapper.UseExpression) {
                    GUIUtility.keyboardControl = 0; // unfocus textfield so it can update.
                }
            }
        }

        if (propertyIsValid != UTFieldValidity.Valid) {
            EditorGUILayout.EndHorizontal ();
            EditorGUILayout.BeginHorizontal ();
            EditorGUILayout.PrefixLabel (" ");
            EditorGUILayout.HelpBox (errorMessage, propertyIsValid == UTFieldValidity.ValidWithWarning ? MessageType.Warning : MessageType.Error);
            EditorGUILayout.EndHorizontal ();
            EditorGUILayout.EndVertical ();
        }

        return removed;
    }
Exemple #32
0
 public virtual bool DrawArrayMember(UTFieldWrapper wrapper, out bool deleteMember)
 {
     deleteMember = false;
     return(false);
 }
Exemple #33
0
 public virtual bool DrawProperty(UTFieldWrapper wrapper)
 {
     return(false);
 }
Exemple #34
0
 public virtual UTFieldValidity CheckValidity(UTFieldWrapper wrapper, out string errorMessage)
 {
     return(defaultChecker.CheckValidity(wrapper, out errorMessage));
 }
 public virtual bool DrawProperty(UTFieldWrapper wrapper)
 {
     return false;
 }
 public virtual bool DrawArrayMember(UTFieldWrapper wrapper, out bool deleteMember)
 {
     deleteMember = false;
     return false;
 }
 public virtual UTFieldValidity CheckValidity(UTFieldWrapper wrapper, out string errorMessage)
 {
     return defaultChecker.CheckValidity(wrapper, out errorMessage);
 }
    protected virtual bool DrawProperty(UTFieldWrapper wrapper, bool removeable)
    {
        string          errorMessage    = "";
        UTFieldValidity propertyIsValid = fieldValidityChecker == null ? UTFieldValidity.Valid :
                                          fieldValidityChecker.CheckValidity(wrapper, out errorMessage);

        if (propertyIsValid != UTFieldValidity.Valid)
        {
            EditorGUILayout.BeginVertical();
            EditorGUILayout.BeginHorizontal();
        }

        bool isRenderedByDelegate = rendererDelegate != null && rendererDelegate.DrawProperty(wrapper);
        bool removed = false;

        if (!isRenderedByDelegate)
        {
            if (wrapper.SupportsExpressions)
            {
                if (wrapper.UseExpression)
                {
                    if (wrapper.Label != null)
                    {
                        wrapper.Expression = EditorGUILayout.TextField(wrapper.Label, wrapper.Expression);
                    }
                    else
                    {
                        wrapper.Expression = EditorGUILayout.TextField(wrapper.Expression);
                    }
                }
            }

            if (!wrapper.SupportsExpressions || !wrapper.UseExpression)
            {
                var fieldType = wrapper.FieldType;
                if (fieldType.IsArray)
                {
                    fieldType = fieldType.GetElementType();
                }
                var renderer = UTPropertyRendererRegistry.GetRendererForType(fieldType);
                if (renderer != null)
                {
                    renderer.Render(wrapper);
                }
                else
                {
                    EditorGUILayout.HelpBox("Missing renderer for property " + wrapper.FieldName + " of type " + fieldType.FullName, MessageType.Warning);
                }
            }
        }
        if (removeable)
        {
            if (GUILayout.Button(UTEditorResources.DeleteIcon, UTEditorResources.DeleteButtonStyle))
            {
                removed = true;
            }
        }
        if (!isRenderedByDelegate)
        {
            if (wrapper.SupportsExpressions)
            {
                var oldExpression = wrapper.UseExpression;
                wrapper.UseExpression = GUILayout.Toggle(oldExpression, UTEditorResources.ExpressionButton, UTEditorResources.ExpressionButtonStyle);
                if (oldExpression != wrapper.UseExpression)
                {
                    GUIUtility.keyboardControl = 0;                     // unfocus textfield so it can update.
                }
            }
        }

        if (propertyIsValid != UTFieldValidity.Valid)
        {
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.PrefixLabel(" ");
            EditorGUILayout.HelpBox(errorMessage, propertyIsValid == UTFieldValidity.ValidWithWarning ? MessageType.Warning : MessageType.Error);
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.EndVertical();
        }

        return(removed);
    }
    public void Render(UTFieldWrapper wrapper)
    {
        var lineHeight = 20;

        var val = (string)wrapper.Value;

        if (val == null)
        {
            val = "";
        }

        if (wrapper.Label != null)
        {
            if (wrapper.InspectorHint.displayAs == UTInspectorHint.DisplayAs.TextArea)
            {
                EditorGUILayout.BeginVertical();
                EditorGUILayout.LabelField(wrapper.Label);
                wrapper.Value = EditorGUILayout.TextArea(val, GUILayout.Height(wrapper.InspectorHint.lines * lineHeight));
                EditorGUILayout.EndVertical();
            }
            else if (wrapper.InspectorHint.displayAs == UTInspectorHint.DisplayAs.Password)
            {
                wrapper.Value = EditorGUILayout.PasswordField(wrapper.Label, val);
            }
            else
            {
                wrapper.Value = EditorGUILayout.TextField(wrapper.Label, val);
            }
        }
        else
        {
            if (wrapper.InspectorHint.displayAs == UTInspectorHint.DisplayAs.TextArea)
            {
                wrapper.Value = EditorGUILayout.TextArea(val, GUILayout.Height(wrapper.InspectorHint.lines * lineHeight));
            }
            else if (wrapper.InspectorHint.displayAs == UTInspectorHint.DisplayAs.Password)
            {
                wrapper.Value = EditorGUILayout.PasswordField(val);
            }
            else
            {
                wrapper.Value = EditorGUILayout.TextField(val);
            }
        }
        if (wrapper.InspectorHint.displayAs == UTInspectorHint.DisplayAs.FolderSelect ||
            wrapper.InspectorHint.displayAs == UTInspectorHint.DisplayAs.SaveFileSelect ||
            wrapper.InspectorHint.displayAs == UTInspectorHint.DisplayAs.OpenFileSelect)
        {
            if (GUILayout.Button(UTEditorResources.FolderIcon, UTEditorResources.FolderButtonStyle))
            {
                var path   = !string.IsNullOrEmpty((string)wrapper.Value) ? (string)wrapper.Value : UTFileUtils.ProjectRoot;
                var result = "";
                switch (wrapper.InspectorHint.displayAs)
                {
                case UTInspectorHint.DisplayAs.FolderSelect:
                    result = EditorUtility.OpenFolderPanel(wrapper.InspectorHint.caption, path, "");
                    break;

                case UTInspectorHint.DisplayAs.OpenFileSelect:
                    result = EditorUtility.OpenFilePanel(wrapper.InspectorHint.caption, path, wrapper.InspectorHint.extension);
                    break;

                case UTInspectorHint.DisplayAs.SaveFileSelect:
                    result = EditorUtility.SaveFilePanel(wrapper.InspectorHint.caption, path, "", wrapper.InspectorHint.extension);
                    break;
                }
                if (!string.IsNullOrEmpty(result))
                {
                    wrapper.Value = result;
                }
            }
        }
    }
    protected virtual bool DrawPropertyArrayMember(UTFieldWrapper fieldWrapper)
    {
        var delete = false;
        if (rendererDelegate == null || !rendererDelegate.DrawArrayMember (fieldWrapper, out delete)) {
            EditorGUILayout.BeginHorizontal ();
            delete = DrawProperty (fieldWrapper, true);
            EditorGUILayout.EndHorizontal ();

        }
        return delete;
    }