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;
}
}