BloodAndGore/Assets/Scripts/Environment/SpriteChanger.cs
2019-08-19 01:55:08 +03:00

28 lines
809 B
C#

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! (" + Index + ") for " + gameObject.name);
return false;
}
Sprite.sprite = Sprites[Index];
return true;
}
}
}