RiftMayhem/Assets/Scripts/Items/SpriteIndexer.cs
Pedro Gomes 9c136817b3 Updates to rogue-lite mechanics (WIP)
- visual update on riftraids
- ability unlock system through ability tomes
- (possible) bugfix sprite issue
- player reputation level
2025-01-18 23:14:12 +00:00

60 lines
1.3 KiB
C#

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<Sprite> Sprites = new List<Sprite>();
public Sprite GetSpriteByName(string name)
{
for (int i = 0; i < Sprites.Count; i++)
{
if (Sprites[i].name == name)
return Sprites[i];
}
return null;
}
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.LoadAll<Sprite>("Icons/"))
{
if (Sprites.Contains(item)) continue;
Sprites.Add(item);
}
}*/
}