BloodAndGore/Assets/Scripts/Environment/SpriteChanger.cs

28 lines
770 B
C#
Raw Normal View History

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Saltosion.OneWeapon.Environment {
public class SpriteChanger : MonoBehaviour {
public SpriteRenderer Sprite;
public List<Sprite> Sprites = new List<Sprite>();
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!");
return false;
}
Sprite.sprite = Sprites[Index];
return true;
}
}
}