using System.Collections; using System.Collections.Generic; using UnityEngine; namespace Saltosion.OneWeapon.Environment { public class SpriteChanger : MonoBehaviour { public SpriteRenderer Sprite; public List Sprites = new List(); public int InitialIdx = 0; private int CurrentIdx = 0; void Start() { CurrentIdx = Mathf.Clamp(InitialIdx, 0, Sprites.Count - 1); } public bool SetSprite(int Index) { if (Index < 0 || Index >= Sprites.Count) { Debug.LogError("Cannot change sprite to an index that does not exist! (" + Index + ") for " + gameObject.name); return false; } Sprite.sprite = Sprites[Index]; return true; } } }