using System.Collections.Generic; using UnityEngine; namespace MalbersAnimations.Scriptables { public abstract class ScriptableList : ScriptableObject where T : Object { [TextArea(3, 20)] public string Description = "Store a List of Objects"; [SerializeField] private List items = new List(); /// Ammount of object on the list public int Count => items.Count; public List Items { get => items; set => items = value; } /// Gets a rando first object of the list public virtual T Item_GetRandom() { if (items != null && items.Count > 0) { return items[Random.Range(0, items.Count)]; } return default; } /// Gets an object on the list by an index public virtual T Item_Get(int index) => items[index % items.Count]; /// Gets the first object of the list public virtual T Item_GetFirst() => items[0]; public virtual T Item_Get(string name) => items.Find(x => x.name == name); } }