using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class ChangeImage : MonoBehaviour { public Image hand1; public Image hand2; public List hands = new List(); private float timer = 0; //void C(Image show1, Image show2) //{ // for (int j = 0; j < hands.Count; j++) // { // string spriteName = hands[j].name; // if (show1.mainTexture.name != spriteName) continue; // show2.mainTexture = j < hands.Count - 1 ? hands[j + 1] : hands[0]; // } //} // Update is called once per frame void Update() { timer += Time.deltaTime; if (hand1.gameObject.activeSelf && timer >= 0.5) { hand1.gameObject.SetActive(false); hand2.gameObject.SetActive(true); timer = 0; } else if (hand2.gameObject.activeSelf && timer >= 0.5) { hand2.gameObject.SetActive(false); hand1.gameObject.SetActive(true); timer = 0; } } }