Skip to content

Commit 0c15c7e

Browse files
committed
2 parents 2bb8080 + e35b0dc commit 0c15c7e

1 file changed

Lines changed: 82 additions & 1 deletion

File tree

README.md

Lines changed: 82 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,83 @@
11
# ScriptableObjectDropdown
2-
Dropdown for ScriptableObjects
2+
ScriptableObjectDropdown is an attribute for the Unity Inspector.
3+
It is used for showing ScriptableObjects which are created in your project, in dropdown menu in Inspector.
4+
5+
# Usage Example
6+
This is `ScriptableObject` class which you create object with it.
7+
8+
```cs
9+
using UnityEngine;
10+
11+
[CreateAssetMenu(menuName = "Create Block")]
12+
public class Block : ScriptableObject
13+
{
14+
// Some fields
15+
}
16+
```
17+
18+
Then you should put those created ScriptableObjects in `Resources` folder.
19+
20+
![](Images/Resources.PNG)
21+
22+
Now we want to use `ScriptableObjectDropdown` attribute. We can use this attribute in both `MonoBeahviour` and `ScriptableObject` derived classes.
23+
24+
**MonoBehavior**
25+
26+
```cs
27+
using ScriptableObjectDropdown;
28+
using UnityEngine;
29+
30+
public class BlockManager : MonoBehaviour
31+
{
32+
// Without grouping (default is None)
33+
[ScriptableObjectDropdown] public Block firstTargetBlock;
34+
// By grouping
35+
[ScriptableObjectDropdown(grouping = ScriptableObjectGrouping.ByFolder)] public Block secondTargetBlock;
36+
}
37+
```
38+
39+
![](Images/MonoBehaviourDefaultGrouping.png)
40+
41+
![](Images/MonoBehaviourByFolderGrouping.png)
42+
43+
**ScriptableObject**
44+
```cs
45+
using UnityEngine;
46+
using ScriptableObjectDropdown;
47+
48+
[CreateAssetMenu(menuName ="Create Block Manager Settings")]
49+
public class BlockManagerSettings : ScriptableObject
50+
{
51+
// Without grouping (default is None)
52+
[ScriptableObjectDropdown] public Block firstTargetBlock;
53+
// By grouping
54+
[ScriptableObjectDropdown(grouping = ScriptableObjectGrouping.ByFolderFlat)] public Block secondTargetBlock;
55+
}
56+
```
57+
58+
![](Images/ScriptableObjectDefaultGrouping.png)
59+
60+
![](Images/ScriptableObjectByFolderFlatGrouping.png)
61+
62+
# License
63+
MIT License
64+
65+
Copyright (c) 2019 Alireza Tarahomi
66+
67+
Permission is hereby granted, free of charge, to any person obtaining a copy
68+
of this software and associated documentation files (the "Software"), to deal
69+
in the Software without restriction, including without limitation the rights
70+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
71+
copies of the Software, and to permit persons to whom the Software is
72+
furnished to do so, subject to the following conditions:
73+
74+
The above copyright notice and this permission notice shall be included in all
75+
copies or substantial portions of the Software.
76+
77+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
78+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
79+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
80+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
81+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
82+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
83+
SOFTWARE.

0 commit comments

Comments
 (0)