Pro Only: Weaver Lite allows you to try out asset lists in the Unity Editor, but they will always be empty in a runtime build unless you purchase Weaver Pro.
Creating and using an asset list is easy:
- Use the Assets/Create/Asset List menu item or Right Click in the Project window and select Create/Asset List.
- Set the
Directoryyou want it to target. It will automatically target the directory it was created in by default.
- Select the
Asset Typeyou want the list to include.
- This requires the type of the list itself to be changed so it will show the
Change List Typebox which allows you to either select an existing list type if there is one for the chosen asset type, or allows you to generate a new list type.
- Newly generated list type scripts are saved in the
Output Directoryspecified in the Procedural Assets Panel, but you can move them anywhere you like after that.
- Note that you need to set the
Directoryfirst because the dropdown menu will only show asset types that are actually in that folder
- You can also manually create a class that inherits from
AssetList<T>if you want to.
- Then you can reference the list you created like any other asset, such as with a serialized field, via Asset Injection, or using
Resources.Load. For example, the
MissileRainscript simply has a
[SerializeField] private MissileList _MissilePrefabs.
Asset Lists Panel
Unfortunately due to technical limitations of Unity's serialization system, assets cannot be a generic type. This means that the Missiles example cannot simply make an
AssetList<Missile>, it has to declare a non-generic type that inherits from it (
MissileList : AssetList<Missile>) and use that type instead. To deal with this, the
Change List Type box in the Asset List inspector streamlines the process of generating a new list type and the Asset Lists Panel shows all list types and makes it easy to delete old ones which are no longer used in the project.