RiftMayhem/Assets/Scripts/Items/SpriteIndexer.cs
Pedro Gomes d75d51a9c4 Gameplay update
- Added multiple input modes:
   - Point and click (as before)
   - WASD + mouse aiming (fully supported) (need QoL for interactables)
   - Gamepad controls (partial support)

- Sprite indexer to avoid gamebreaking issues when serializing sprites
- Movement speed penalty on casting abilities instead of fully stopping agent
2025-01-17 20:16:02 +00:00

49 lines
1.0 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>();
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<Sprite>())
{
if (Sprites.Contains(item)) continue;
Sprites.Add(item);
}
}
}