Skip to content

Commit 9fbf92d

Browse files
committed
Add AssetPath attribute usage description to README.md
1 parent 2be2af8 commit 9fbf92d

File tree

4 files changed

+94
-2
lines changed

4 files changed

+94
-2
lines changed

Documentation/asset-path-example.png

706 KB
Loading

Documentation/asset-path-example.png.meta

+74
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

+19-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
# Unity Forge Property Drawers [![License](https://img.shields.io/badge/license-MIT-lightgrey.svg?style=flat)](http://mit-license.org)
1+
[![license](https://img.shields.io/github/license/rfadeev/unity-forge-property-drawers.svg)](https://github.com/rfadeev/unity-forge-property-drawers/blob/master/LICENSE.md)
2+
# Unity Forge Property Drawers
23
Custom propery drawers to ease fields value management in Unity editor.
34

45
## Attributes list
56
* [AnimationName](#animationname)
67
* [AnimatorLayerName](#animatorlayername)
78
* [AnimatorParameterName](#animatorparametername)
89
* [AnimatorStateName](#animatorstatename)
10+
* [AssetPath](#assetpath)
911
* [GameObjectLayer](#gameobjectlayer)
1012
* [GameObjectTag](#gameobjecttag)
1113
* [ScenePath](#scenepath)
@@ -100,6 +102,22 @@ private string exampleStateName;
100102
### Caveats
101103
Since layer index is [decoupled](https://docs.unity3d.com/ScriptReference/Animator.Play.html) from animator state name in Unity API, state name alone does not determine state and state index value should be managed separately. If only one animation layer is used, it's not the problem and `Play(string stateName)` overload can be used safely for fields using `AnimatorStateName` attribute.
102104

105+
## AssetPath
106+
![screencast](Documentation/asset-path-example.png)
107+
108+
### Attribute usage
109+
Add attribute to string field to enable show object field instead of text input for object path. Object selection updates serialized value of the string field. Attribute declataion requires object type. Attribute supports both full project path (like "Assets/Sprites/MySpriteA.png") and resources path type (like "Sprites/MySpriteB" for full path value "Assets/Resources/Sprites/MySpriteB.png"). Additionnal option allows to preview path value which is serialized.
110+
```csharp
111+
[SerializeField, AssetPath(typeof(Sprite), false)]
112+
private string spriteProjectPath01;
113+
[SerializeField, AssetPath(typeof(Sprite), true)]
114+
private string spriteResourcesPath01;
115+
[SerializeField, AssetPath(typeof(Sprite), false, true)]
116+
private string spriteProjectPath02;
117+
[SerializeField, AssetPath(typeof(Sprite), true, true)]
118+
private string spriteResourcesPath02;
119+
```
120+
103121
## GameObjectLayer
104122
![screencast](Documentation/game-object-layer-example.png)
105123

Source/PropertyAttributes/AssetPathAttribute.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ namespace UnityForge
55
{
66
/// <summary>
77
/// An attribute that can be placed on a string field to make it appear in
8-
/// the inspector as an object picker for the specified typeand the
8+
/// the inspector as an object picker for the specified type and the
99
/// selected objects path will be saved to the string field.
1010
/// </summary>
1111
[AttributeUsage(AttributeTargets.Field, AllowMultiple = false)]

0 commit comments

Comments
 (0)