Version 3.3.1.2

Odin has a dedicated attribute overview with examples

FolderPathAttribute class

Namespace: Sirenix.OdinInspector
Assembly: Sirenix.OdinInspector.Attributes
[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Module | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Interface | AttributeTargets.Parameter | AttributeTargets.Delegate | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter | AttributeTargets.All, AllowMultiple = false, Inherited = true)]
[Conditional("UNITY_EDITOR")]
public sealed class FolderPathAttribute : Attribute, _Attribute

FolderPath is used on string properties, and provides an interface for directory paths.

Inheritance
  • System.Object
  • System.Attribute
  • FolderPathAttribute
Example

The following example demonstrates how FolderPath is used.

public class FolderPathExamples : MonoBehaviour
{
	// By default, FolderPath provides a path relative to the Unity project.
	[FolderPath]
	public string UnityProjectPath;

	// It is possible to provide custom parent patn. ParentFolder paths can be relative to the Unity project, or absolute.
	[FolderPath(ParentFolder = "Assets/Plugins/Sirenix")]
	public string RelativeToParentPath;

	// Using ParentFolder, FolderPath can also provide a path relative to a resources folder.
	[FolderPath(ParentFolder = "Assets/Resources")]
	public string ResourcePath;

	// By setting AbsolutePath to true, the FolderPath will provide an absolute path instead.
	[FolderPath(AbsolutePath = true)]
	public string AbsolutePath;

	// FolderPath can also be configured to show an error, if the provided path is invalid.
	[FolderPath(RequireValidPath = true)]
	public string ValidPath;

	// By default, FolderPath will enforce the use of forward slashes. It can also be configured to use backslashes instead.
	[FolderPath(UseBackslashes = true)]
	public string Backslashes;

	// FolderPath also supports member references with the $ symbol.
	[FolderPath(ParentFolder = "$DynamicParent")]
	public string DynamicFolderPath;

	public string DynamicParent = "Assets/Plugins/Sirenix";
}

Constructors

FolderPathAttribute()
public FolderPathAttribute()

Fields

AbsolutePath
If true the FolderPath will provide an absolute path, instead of a relative one.
public bool AbsolutePath
ParentFolder
ParentFolder provides an override for where the path is relative to. ParentFolder can be relative to the Unity project, or an absolute path. Supports member referencing with $.
public string ParentFolder
RequireExistingPath
If true an error will be displayed for non-existing paths.
public bool RequireExistingPath
UseBackslashes
By default FolderPath enforces forward slashes. Set UseBackslashes to true if you want backslashes instead.
public bool UseBackslashes