How i can fix this code ?

Hello, I want to play multiple pictures to make a video effect. I try videotexture but its very unstable.
I try with coroutine but its looping all the time the condition its true but I just playing the pictures only once. DO you have an idea ? Thanks!

using UnityEngine;
using System.Collections;
using UnityEngine.UI;

public class Salma : MonoBehaviour
{

	

	public Texture Avertissement1;
	public Texture Avertissement2;
	public Texture Avertissement3;
    public Texture Avertissement4;
	public Texture Avertissement5;
	public Texture Avertissement6;
	public Texture Avertissement7;
	public Texture Avertissement8;
	public Texture Avertissement9;
	public Texture Avertissement10;
	public Texture Avertissement11;
	public Texture Avertissement12;
	public Texture Avertissement13;
	

	public GameObject object1;
	public GameObject object2; 


		void Update ()
		{
				float distance = Vector3.Distance (object1.transform.position, object2.transform.position);
				print (distance);


				if (distance >= 10 && distance < 20 )

				{ 

						StartCoroutine (Disparition());


				} 
		
		}
		

		IEnumerator Disparition ()
		{

				yield return null;
				GetComponent<RawImage> ().texture = Avertissement1 as Texture;
				yield return new WaitForSeconds (0.3f);
				GetComponent<RawImage> ().texture = Avertissement2 as Texture;
				yield return new WaitForSeconds (0.3f);
				GetComponent<RawImage> ().texture = Avertissement3 as Texture;
				yield return new WaitForSeconds (0.3f);
				GetComponent<RawImage> ().texture = Avertissement4 as Texture;
				yield return new WaitForSeconds (0.3f);
				GetComponent<RawImage> ().texture = Avertissement5 as Texture;
				yield return new WaitForSeconds (0.3f);
				GetComponent<RawImage> ().texture = Avertissement6 as Texture;
				yield return new WaitForSeconds (0.3f);
				GetComponent<RawImage> ().texture = Avertissement7 as Texture;
				yield return new WaitForSeconds (0.3f);
				GetComponent<RawImage> ().texture = Avertissement8 as Texture;
				yield return new WaitForSeconds (0.3f);
				GetComponent<RawImage> ().texture = Avertissement9 as Texture;
				yield return new WaitForSeconds (0.3f);
				GetComponent<RawImage> ().texture = Avertissement10 as Texture;
				yield return new WaitForSeconds (0.3f);
				GetComponent<RawImage> ().texture = Avertissement11 as Texture;
				yield return new WaitForSeconds (0.3f);
				GetComponent<RawImage> ().texture = Avertissement12 as Texture;
				yield return new WaitForSeconds (0.3f);
				GetComponent<RawImage> ().texture = Avertissement13 as Texture;


		}
		}

I’d suggest using an array instead of multiple variables (iterations if your friend, be nice to it, buy it chocolate, keep its trust). Also since your values are already of type Texture you do not need to use the “as” keyword.

EDIT: Updating the example code to provide more detail closer to original, if you StartCoroutine all the time you will create multiple routines causing the image to jump around a bit. So only play the routine if it is not already running.

ANOTHER EDIT: updated code to cache the RawImage component only once, since there is no sense in getting the component over and over again.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Test : MonoBehaviour
{
    [SerializeField]
    private Texture[] m_Textures;
    [SerializeField]
    private GameObject m_Object1;
    [SerializeField]
    private GameObject m_Object2;

    private Coroutine m_Sequence;
    private RawImage m_RawImage;

    void Update()
    {
        float distance = Vector3.Distance(m_Object1.transform.position, m_Object2.transform.position);
        print(distance);

        if (distance >= 10 && distance < 20)
        {
            if (!m_Sequence == null)
            {
                m_Sequence = StartCoroutine(Disparition(m_Textures));
            }
        }
        else
        {
            StopCoroutine(m_Sequence);
        }
    }

    private IEnumerator Disparition(Texture[] lImages)
    {
        if (m_RawImage == null)
        {
            m_RawImage = GetComponent<RawImage>();
        }
        int lIndex = 0;
        while (lIndex < lImages.Length)
        {
            // Display image.
            m_RawImage.texture = lImages[lIndex] as Texture;
            yield return new WaitForSeconds(0.3f);
            lIndex++;
        }
        m_Sequence = null;
    }
}