Пример #1
0
        /// <summary>
        /// Not yet documented.
        /// </summary>
        protected override void DrawPropertyLayout(IPropertyValueEntry <string> entry, FilePathAttribute attribute, GUIContent label)
        {
            // Create a property context for parent path and extensions options.
            InspectorProperty parentProperty = entry.Property.FindParent(PropertyValueCategory.Member, true);
            PropertyContext <FilePathContext> context;

            if (entry.Context.Get(this, "FilePathContext", out context))
            {
                context.Value            = new FilePathContext();
                context.Value.Parent     = new StringMemberHelper(parentProperty.ParentType, attribute.ParentFolder, ref context.Value.ErrorMessage);
                context.Value.Extensions = new StringMemberHelper(parentProperty.ParentType, attribute.Extensions, ref context.Value.ErrorMessage);
                context.Value.Exists     = PathExists(entry.SmartValue, context.Value.Parent.GetString(entry));
            }

            // Display evt. errors in creating property context.
            if (context.Value.ErrorMessage != null)
            {
                AllEditorGUI.ErrorMessageBox(context.Value.ErrorMessage);
            }

            // Display required path error, if enabled.
            if (attribute.RequireValidPath && context.Value.Exists == false)
            {
                AllEditorGUI.ErrorMessageBox("The path is invalid.");
            }

            // Draw the field.
            EditorGUI.BeginChangeCheck();
            entry.SmartValue = SirenixEditorFields.FilePathField(label, entry.SmartValue, context.Value.Parent.GetString(parentProperty), context.Value.Extensions.GetString(entry), attribute.AbsolutePath, attribute.UseBackslashes);

            // Update exists check.
            if (EditorGUI.EndChangeCheck() && attribute.RequireValidPath)
            {
                context.Value.Exists = PathExists(entry.SmartValue, context.Value.Parent.GetString(entry));
                GUI.changed          = true;
            }
        }
Пример #2
0
        /// <summary>
        /// Not yet documented.
        /// </summary>
        protected override void DrawPropertyLayout(GUIContent label)
        {
            // Display evt. errors in creating property context.
            if (this.errorMessage != null)
            {
                SirenixEditorGUI.ErrorMessageBox(this.errorMessage);
            }

            // Gotta check that constantly, the value can change from outside the inspector!
            //if (requireExistingPath && Event.current.type == EventType.Layout)
            //{
            //    this.exists = this.PathExists(this.ValueEntry.SmartValue, this.parent.GetString(this.Property));
            //}

            // Display required path error, if enabled.
            //if (this.requireExistingPath && this.exists == false)
            //{
            //    SirenixEditorGUI.ErrorMessageBox("The path does not exist.");
            //}

            // Draw the field.
            EditorGUI.BeginChangeCheck();
            this.ValueEntry.SmartValue = SirenixEditorFields.FilePathField(
                label,
                this.ValueEntry.SmartValue,
                this.parent.GetString(this.parentProperty),
                this.extensions.GetString(this.ValueEntry),
                this.Attribute.AbsolutePath,
                this.Attribute.UseBackslashes);

            // Update exists check.
            //if (EditorGUI.EndChangeCheck() && this.requireExistingPath)
            //{
            //    this.exists = this.PathExists(this.ValueEntry.SmartValue, this.parent.GetString(this.Property));
            //    GUI.changed = true;
            //}
        }