using Kryz.CharacterStats.Examples; using System.Collections; using System.Collections.Generic; using UnityEngine; public class SpriteIndexer : MonoBehaviour { #region Singleton private static SpriteIndexer _instance; // Public reference to the singleton instance public static SpriteIndexer Instance { get { return _instance; } } #endregion public List Sprites = new List(); protected void Awake() { // Ensure there's only one instance if (_instance != null && _instance != this) { Destroy(gameObject); return; } // If this is the first instance, set it as the singleton _instance = this; DontDestroyOnLoad(gameObject); } private void OnValidate() { if (Sprites == null) return; foreach (Sprite item in Resources.FindObjectsOfTypeAll()) { if (Sprites.Contains(item)) continue; Sprites.Add(item); } } }