the image load to fast when i click button , can you help me ? thank best regard
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Sprites;
using UnityStandardAssets.CrossPlatformInput;
public class LoadSprite : MonoBehaviour
{
public int i = 0;
public Sprite[] gallery ;
public IEnumerator ThayAnh()
{
Image anhUI = this.GetComponent<Image>();
if (CrossPlatformInputManager.GetButton("Next"))
{
if (i + 1 < gallery.Length)
{
yield return new WaitForSeconds(0.5f);
i++;
}
anhUI.sprite = gallery[i];
}
if (CrossPlatformInputManager.GetButton("Pre"))
{
if (i - 1 > 0)
{
yield return new WaitForSeconds(0.5f);
i--;
}
anhUI.sprite = gallery[i];
}
}
void Update()
{
StartCoroutine( ThayAnh());
}
}