public virtual bool IsMessageBoxShown(SerializedProperty property, FolderPathAttribute attribute)
        {
            bool showMessage = false;

            if ((attribute != null) && (attribute.IsWarningDisplayed == true))
            {
                // FIXME: check local path
                showMessage = (Directory.Exists(property.stringValue) == false);
            }
            return(showMessage);
        }
        protected virtual void OpenDialog(SerializedProperty property, GUIContent label)
        {
            // Open a folder panel
            FolderPathAttribute path = (FolderPathAttribute)attribute;
            string browsedFolder     = EditorUtility.OpenFolderPanel(label.text, path.DefaultPath, null);

            // Check if a folder was found
            if (string.IsNullOrEmpty(browsedFolder) == false)
            {
                property.stringValue = GetLocalPath(browsedFolder, path.PathRelativeTo);
            }
        }
Example #3
0
 public override void ProcessChildMemberAttributes(
     InspectorProperty parentProperty,
     MemberInfo member,
     List <Attribute> attributes)
 {
     if (member.Name == "Value")
     {
         var folderPathAttribute = new FolderPathAttribute {
             AbsolutePath = true, RequireExistingPath = true
         };
         attributes.Add(folderPathAttribute);
     }
 }
Example #4
0
    //EDITOR METHODS
    public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
    {
        switch (property.propertyType)
        {
        case SerializedPropertyType.String:
            FolderPathAttribute attr = (FolderPathAttribute)attribute;

            string resourcesPath = Application.dataPath + "/";
            if (!string.IsNullOrEmpty(attr.folderPathRestriction))
            {
                resourcesPath += attr.folderPathRestriction + "/";
            }
            string path        = property.stringValue;
            var    contentRect = EditorGUI.PrefixLabel(position, label);
            var    textRect    = contentRect;
            var    ButtonRect  = contentRect;

            textRect.width  -= BUTTONS_SIZE * (attr.hasClearButton?2:1);
            ButtonRect.width = BUTTONS_SIZE;
            ButtonRect.x     = textRect.xMax;

            path = EditorGUI.TextField(textRect, path);
            var select = GUI.Button(ButtonRect, "Browse");
            if (select)
            {
                path     = EditorUtility.OpenFolderPanel("Select Folder", resourcesPath + path, "");
                modified = true;
            }

            if (attr.hasClearButton)
            {
                ButtonRect.x += ButtonRect.width;
                var clear = GUI.Button(ButtonRect, "Clear");
                if (clear)
                {
                    property.stringValue = null;
                }
            }

            if (!string.IsNullOrEmpty(path))
            {
                if (modified)
                {
                    if (!path.Contains(resourcesPath))
                    {
                        Debug.Log("The Folder should be located in the " + attr.folderPathRestriction + " folder");
                        modified = false;
                        return;
                    }
                    path = path.Replace(resourcesPath, "");
                    property.stringValue = path;
                    modified             = false;
                }
            }

            break;

        default:
            EditorGUI.LabelField(position, label.text, "Use ResourceFolderPathDrawer with string.");
            break;
        }
    }
Example #5
0
 public FolderPathDrawer(InspectorAttribute attribute) : base(attribute)
 {
     FAttribute = attribute as FolderPathAttribute;
     OpenGC     = EditorGUIUtility.IconContent("Folder Icon");
 }
Example #6
0
 public static string Description(this FolderPathAttribute folderPath)
 {
     return("This is a folder path.");
 }