This package help you create fast Lists of Assets with specified Type, good for prototype your games.
- in Unity go to Windows > Package Manager
- press
+
and selectAdd package from git URL...
https://github.com/gbviktor/scriptable-list-automator.git
- You has Player Avatars in folder
Assets/Content/PlayerAvatars
- Create in folder your Scriptable Object inherited from
BaseListAutomator<SpriteType>
- After this, you get useful List of Assets inside this Folder of Type Sprite
- You can define self id of each Asset
override GetAssetID(string guid, UnityEngine.Object obj, out string id)
- You can register founded Assets by self, if you want to do more
override RegisterAsset(string guid, UnityEngine.Object obj, string id)
- You can filter Assets before add to List
override FilterAssetPassed(Object asset)
- You can define self id of each Asset
- Create in folder your Scriptable Object inherited from
using System.Collections.Generic;
using UnityEngine;
using MontanaGames.ListAutomator;
[CreateAssetMenu(menuName = "/Demo/Audio List", fileName = "AudioList")]
public class AudioListSO : AutomatorListBase<AssetItem<AudioClip>, AudioClipType>
{
[Tooltip("If requested AudioClip not found, you receive defaulAudioClip")]
[SerializeField] AudioClip defaultAudioClip;
[SerializeField] List<AudioClip> sounds = new List<AudioClip>();
public IReadOnlyList<AudioClip> Sounds => sounds;
protected override void RegisterAsset(string guid, Object obj, string id)
{
if (obj is AudioClip audioClip)
{
if(!sounds.Contains(audioClip))
sounds.Add(audioClip);
}
}
//setup/generate your ids for Asset, how you like
protected override void GetAssetID(string guid, Object obj, out string id)
{
if (obj is not AudioClip clip)
throw new ArgumentException($"File has wrong type {obj.GetType()}, excepted Type is {typeof(AudioClip)}");
id = "id#"+obj.name;
}
//feel free to filter founded assets like a bird
protected override bool FilterAssetPassed(string guid, Object assset)
=> assset is AudioClip;
}
PrefabType
- to find PrefabsScriptbleObjectType
- to find Scriptable ObjectsAssetType
- similar toScriptableObjectType
SpriteType
- to find Sprites (not textures)MaterialType
- to find MaterialsAudioClipType
- to find Audio Clips it's simple...
- UniTask not required
- Unity Addressable - later will be optional, it will be moved to Samples
- Newtonsoft.Json