Unity Quick Dropdown
C# Attributes that allow you to quickly assign Unity assets from a Dropdown on the Inspector.
com.phengine.quickdropdown 
Install via UPM
Add to Unity Package Manager using this URL
https://www.pkglnk.dev/quickdropdown.git README Markdown
Copy this to your project's README.md
## Installation
Add **Unity Quick Dropdown** to your Unity project via Package Manager:
1. Open **Window > Package Manager**
2. Click **+** > **Add package from git URL**
3. Enter:
```
https://www.pkglnk.dev/quickdropdown.git
```
[](https://www.pkglnk.dev/pkg/quickdropdown)README
⚡Unity Quick Dropdown
C# Attributes that allow you to quickly assign Unity assets from a Dropdown on the Inspector. Support any UnityEngine.Object types. Help save time and reduce human errors by letting you pick an object from your desired location.
[!NOTE] This Library is not an Official Library from Unity.
Overview
[FromFolder] - Display a Dropdown of Unity Assets from a specific Folder.
[FromGroup] - Display a Dropdown of Unity Assets from the
ScriptableGroupwith a matching name.- Using
ScriptableGroupsallows you to move the assets in the project around without losing their group organization. - You can nest ScriptableGroup inside each other. Cyclic references are also prevented and filtered out.
- Using
[FromConfig] - Display a Dropdown of Unity Assets from a first found
ScriptableContainerwith a specified type.- This is useful for looking up objects from a ScriptableObject that is meant to be a singular "Config" or "Setting" (a Singleton if you will)
[FromAddressable] - Display a Dropdown of Addressable Assets from a specific Addressable Group.
Supported List & Array (Both direct usage & nested elements)
QoL Features:
- Select & Jump to the assigned asset or its enclosing location.
- You get a Fix button for creating a new source if it does not exist.
- An Inspect button allows you to quickly open a floating property window of the assigned asset.
- Warn user if the assigned object does not belong to the specified location.
- Warn about invalid locations.
- Supports nested dropdown.
- Easily customize how the Dropdown look using attribute parameters.
- Supports Multi-Edit.
- Undo-Friendly.
For ScriptableObjects:
- Quickly create new instances of
ScriptableObjectand add them into the specified location from a+button. When creating a new asset this way, the enclosing Folder / ScriptableGroup are also created automatically if they didn't exist.
- Quickly create new instances of
Installation
There are 2 options to install the package:
- A) Download source code and put them into the Unity's Assets folder
- B) Install from the Package Manager using this git URL: https://github.com/phanphantz/Unity-Quick-Dropdown.git
Quick Example
using PhEngine.QuickDropdown;
using UnityEngine;
public class QuickDropdownExample : MonoBehaviour
{
public float health;
//Let user pick 'ElementConfig' asset from the ScriptableGroup named 'TestGroup' in the asset folder.
//By default, This also display Inspect button, Create button (Only for ScriptableObjects), and a mini button to jump to the enclosing group.
[FromGroup("TestGroup"), SerializeField]
ElementConfig element;
//Let user pick 'ElementConfig' from a first found ScriptableObject with the type of 'SampleConfig'
[FromConfig(typeof(SampleConfig)), SerializeField]
ElementConfig sampleConfigItem;
public float attack;
public float stamina;
//Let user pick Sprite from the folder 'Assets/Sprites' and all the subfolders below.
//The folder information is hidden from 'isHideInfo' flag
//These path variations also work: 'Assets/Sprites', 'Assets/Sprites/', 'Sprites/'
[FromFolder("Sprites", isHideInfo: true), SerializeField]
Sprite sprite;
//By default, Inspect button will open the assigned asset as a floating window.
//You can change the button behaviour using different InpsectModes
[FromFolder("Prefabs", inspectMode: InspectMode.Select), SerializeField]
GameObject prefab;
}
Result:
List & Array Support
//Quick Dropdown now directly supports List & Array
[FromGroup("TestGroup"), SerializeField]
List<ElementConfig> directList = new List<ElementConfig>();
[FromGroup("TestGroup"), SerializeField]
ElementConfig[] directArray = new ElementConfig[] {};
//Nested List & Array also works
[SerializeField] List<ElementConfigData> nestedDropdownList = new List<ElementConfigData>();
[SerializeField] ElementConfigData[] nestedDropdownArray = new ElementConfigData[] {};
Addressables Support
If you have the Addressables package installed in the project, you can use [FromAddressable] attribute on Unity Object fields and string fields to display a dropdown of Addressable assets from a desired group.
- When you specify an Addressable group name that does not exist. You also get the Fix button on the inspector to quickly create it.
- Creating ScriptableObjects using Create button from the inspector will also add the created asset to the target Addressable Group.
using PhEngine.QuickDropdown.Addressables;
using UnityEngine;
public class AddressableDropdownExample : MonoBehaviour
{
[FromAddressable("PackedAddressableGroup"), SerializeField]
ElementConfig addressableConfig;
[FromAddressable("PackedAddressableGroup"), SerializeField]
string addressableAddress;
}
[!NOTE] Unfortunately [FromAddressable] does not work with AssetReference at the moment. Since it is drawn by its own property drawer.
Future Plans
- [FromScene] attribute.
- [FromStringList] attribute.
- A way to bind Create functions for creating non-ScriptableObject assets.
- A Popup UGUI to specify the name of the asset upon creation.
Please feel free to Contribute and send me Pull requests. You can also Buy me a coffee!☕
No comments yet. Be the first!