Changing GUI texture every 3 seconds?

How do you cycle through images in a panel? When my GO stops an Emoji icon appears on top of it and I would like it to change every other second until it gets moving again. Any tips?

public class Emotion : MonoBehaviour {
	public GameObject Sphere;
	public Canvas Emoji;
	private bool hide = false;
	private bool show = true;
	private bool  Tigil = false;
	float CarSpeed;
	Stop stop;

	void PopUp()
	{
		if (stop.SPEED == 0) {
			Emoji.GetComponent<Canvas> ().enabled = show;
			Tigil = true;
		} else if (Tigil) 
		{
			Emoji.GetComponent<Canvas> ().enabled = hide;
			Tigil = false;
		}	
	}
	// Use this for initialization
	void Start () {
		stop = Sphere.GetComponent<Stop>();
		Emoji.GetComponent<Canvas> ().enabled = hide;

	}
	
	// Update is called once per frame
	void Update () {

		PopUp ();

	}
}

If I understand you right, you need to create Image like so
[88150-снимок-экрана-2017-02-16-в-133818.png|88150]

and then write something like this (I write this in browser, so it may contains a bunch of mistakes)

public class Emotion : MonoBehaviour {
     public Image image; // Image that we just created
     public Sprite[] sprites; // your sprites to cycle 
     public int spriteIndex = 0;
     public float timer = 3;
     public GameObject Sphere;
     public Canvas Emoji;
     private bool hide = false;
     private bool show = true;
     private bool  Tigil = false;
     float CarSpeed;
     Stop stop;
 
     void PopUp()
     {
         if (stop.SPEED == 0) {
             Emoji.GetComponent<Canvas> ().enabled = show;
             Tigil = true;
             InvokeRepeat("CycleThroughSprites", timer, timer);
         } else if (Tigil) 
         {
             Emoji.GetComponent<Canvas> ().enabled = hide;
             Tigil = false;
             CancelInvoke("CycleThroughSprites");
         }    
     }
     // Use this for initialization
     void Start () {
         stop = Sphere.GetComponent<Stop>();
         Emoji.GetComponent<Canvas> ().enabled = hide;
 
     }

     void CycleThroughSprites()
     {
           image.sprite = sprites[currentIndex];
           currentIndex++;
           currentIdex %= sprites.Length;
     }
     
     // Update is called once per frame
     void Update () {
 
         PopUp ();
 
     }
 }

Hope it helps
Cheers

You can use a float to count the time remaining to show next image and then when time remaining reaches zero, show next image. This needs to be done only when your character is at rest. Something like:

// Set your images to in this array.
public Sprite[] images;
private int m_CurrentImageIndex;
private float m_TimeRemaingNextImage = 0f;

// Cache your Image component in this in Start() method or assign it from Inspector.
private Image image;

void PopUp()
{
    //-- Your current code goes here.

    if(Tigil) {
        m_TimeRemainingNextImage -= Time.deltaTime;
        if(m_TimeRemainingNextImage <= 0f) {
            image.sprite = images[GetImageIndex()];
            m_TimeRemainingNextImage = 3f;
        }
    }
}

private int GetImageIndex()
{
    m_CurrentImageIndex += 1;
    return (m_CurrentImageIndex >= images.length) ? 0 : m_CurrentImageIndex;
}