Skip to content

Extend FilePath and FolderPath attributes with relative paths and validation#413

Open
Jaeger0624 wants to merge 4 commits into
dbrizov:masterfrom
Jaeger0624:master
Open

Extend FilePath and FolderPath attributes with relative paths and validation#413
Jaeger0624 wants to merge 4 commits into
dbrizov:masterfrom
Jaeger0624:master

Conversation

@Jaeger0624
Copy link
Copy Markdown

Summary

This PR extends FilePathAttribute and FolderPathAttribute with additional drawer options.

Added

  • FilePathAttribute.relativePath
  • Stores selected file paths relative to the Unity project root when enabled.
  • For project assets, this results in paths like Assets/....
  • FolderPathAttribute.relativePath
  • Stores selected folder paths relative to the Unity project root when enabled.
  • FilePathAttribute.validateExists
  • Shows a warning in the Inspector when the field has a value but the referenced file does
    not exist.

Changed

  • Selected paths are applied immediately after using the Browse button.
  • Stored paths are normalized to use forward slashes.
  • Added sample fields in FilePathTest for manual testing.

Compatibility

Existing behavior remains unchanged by default:

  • relativePath defaults to false
  • validateExists defaults to false

Testing

Tested in Unity 6000.3.1f1.

  • Verified scripts compile without errors.
  • Verified relative file paths are stored as Assets/....
  • Verified relative folder paths are stored as Assets/....
  • Verified missing file paths show an Inspector warning when validateExists is enabled.

- [FilePath]: string field with a browse button that opens a file selection dialog
- [FolderPath]: string field with a browse button that opens a folder selection dialog
- Supports customizable title, default directory, and file extension filter
- Includes test components for validation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant