Skip to content

Commit e7bfe42

Browse files
committed
2 parents 8e2e41c + 3ee6a98 commit e7bfe42

File tree

1 file changed

+83
-10
lines changed

1 file changed

+83
-10
lines changed

README.md

Lines changed: 83 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,86 @@ It is used for showing ScriptableObjects which are created in your project, in d
77
# Usage Example
88
1. Clone this repository or download the latest [release package available](https://github.com/ATHellboy/ScriptableObjectMultiSelectDropdown/releases) (There isn't an example folder in `.unitypackage`).
99

10-
2. Create `ScriptableObject` class which you want to create specified objects by that.
10+
2. There are some options here:
11+
* Create a `ScriptableObject` class which you want to create specified objects by that.
1112

1213
```cs
1314
using UnityEngine;
1415

1516
[CreateAssetMenu(menuName = "Create Block")]
1617
public class Block : ScriptableObject
1718
{
18-
// Some fields
19+
// Some fields and functions
20+
}
21+
```
22+
23+
* Create a class that inherits another `ScriptableObject` class.
24+
25+
```cs
26+
using UnityEngine;
27+
28+
[CreateAssetMenu(menuName = "Blocks/Sand")]
29+
public class SandBlock : Block
30+
{
31+
// Some fields and functions
32+
}
33+
```
34+
35+
* Create a abstract `ScriptableObject` class then antoher class which inherits this abstract class.
36+
37+
```cs
38+
using UnityEngine;
39+
40+
public abstract class AbstarctBlock : ScriptableObject
41+
{
42+
// Some fields and functions
43+
}
44+
```
45+
46+
```cs
47+
using UnityEngine;
48+
49+
[CreateAssetMenu(menuName = "Blocks/Water")]
50+
public class WaterBlock : AbstarctBlock
51+
{
52+
// Some fields and functions
53+
}
54+
```
55+
56+
* Create an interface and some `ScriptableObject` classes which inherit this interface. The interface is used for grouping.
57+
58+
```cs
59+
public interface IBlock
60+
{
61+
// Some properties and functions signature
62+
}
63+
```
64+
65+
```cs
66+
using UnityEngine;
67+
68+
[CreateAssetMenu(menuName = "Blocks/Dirt")]
69+
public class DirtBlock : ScriptableObject, IBlock
70+
{
71+
// Some fields and functions
72+
}
73+
```
74+
75+
```cs
76+
using UnityEngine;
77+
78+
[CreateAssetMenu(menuName = "Blocks/Snow")]
79+
public class SnowBlock : ScriptableObject, IBlock
80+
{
81+
// Some fields and functions
1982
}
2083
```
2184

2285
3. Create ScriptableObjects in the project.
2386

2487
![](Images/Resources.PNG)
2588

26-
4. Use `ScriptableObjectMultiSelectDropdown` attribute by setting type of specified ScriptableObject derived class and optional grouping (Default grouping is None) like this in `MonoBeahviour` or `ScriptableObject` derived classes.
89+
4. Use `ScriptableObjectMultiSelectDropdown` attribute by setting type of specified `ScriptableObject` derived class and optional grouping (Default grouping is `None`) behind `ScriptableObjectReference` type variable like these in MonoBeahviour or ScriptableObject derived classes.
2790

2891
**MonoBehavior**
2992

@@ -34,11 +97,16 @@ using UnityEngine;
3497
public class BlockManager : MonoBehaviour
3598
{
3699
// Without grouping (default is None)
37-
[ScriptableObjectMultiSelectDropdown(typeof(Block))]
38-
public ScriptableObjectReference firstTargetBlocks;
100+
[ScriptableObjectMultiSelectDropdown(typeof(Block))] public ScriptableObjectReference targetBlock;
39101
// By grouping
40102
[ScriptableObjectMultiSelectDropdown(typeof(Block), grouping = ScriptableObjectGrouping.ByFolder)]
41-
public ScriptableObjectReference secondTargetBlocks;
103+
public ScriptableObjectReference targetBlockByGrouping;
104+
// Derived class
105+
[ScriptableObjectMultiSelectDropdown(typeof(SandBlock))] public ScriptableObjectReference derivedClassTargetBlock;
106+
// Derived abstract class
107+
[ScriptableObjectMultiSelectDropdown(typeof(AbstarctBlock))] public ScriptableObjectReference derivedAbstractClassTargetBlock;
108+
// Interface
109+
[ScriptableObjectMultiSelectDropdown(typeof(IBlock))] public ScriptableObjectReference interfaceTargetBlock;
42110
}
43111
```
44112

@@ -55,11 +123,16 @@ using ScriptableObjectMultiSelectDropdown;
55123
public class BlockManagerSettings : ScriptableObject
56124
{
57125
// Without grouping (default is None)
58-
[ScriptableObjectMultiSelectDropdown(typeof(Block))]
59-
public ScriptableObjectReference firstTargetBlocks;
126+
[ScriptableObjectMultiSelectDropdown(typeof(Block))] public ScriptableObjectReference targetBlock;
60127
// By grouping
61-
[ScriptableObjectMultiSelectDropdown(typeof(Block), grouping = ScriptableObjectGrouping.ByFolderFlat)]
62-
public ScriptableObjectReference secondTargetBlocks;
128+
[ScriptableObjectMultiSelectDropdown(typeof(Block), grouping = ScriptableObjectGrouping.ByFolder)]
129+
public ScriptableObjectReference targetBlockByGrouping;
130+
// Derived class
131+
[ScriptableObjectMultiSelectDropdown(typeof(SandBlock))] public ScriptableObjectReference derivedClassTargetBlock;
132+
// Derived abstract class
133+
[ScriptableObjectMultiSelectDropdown(typeof(AbstarctBlock))] public ScriptableObjectReference derivedAbstractClassTargetBlock;
134+
// Interface
135+
[ScriptableObjectMultiSelectDropdown(typeof(IBlock))] public ScriptableObjectReference interfaceTargetBlock;
63136
}
64137
```
65138

0 commit comments

Comments
 (0)