2019-08-16 20:46:34 +02:00
|
|
|
|
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);
|
2019-08-16 20:46:34 +02:00
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
Sprite.sprite = Sprites[Index];
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|