BloodAndGore/Assets/Scripts/Environment/SpriteChanger.cs

28 lines
809 B
C#
Raw Permalink 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) {
2019-08-19 00:55:08 +02:00
Debug.LogError("Cannot change sprite to an index that does not exist! (" + Index + ") for " + gameObject.name);
return false;
}
Sprite.sprite = Sprites[Index];
return true;
}
}
}