- Home /
Question by
momenslythe · Mar 17, 2016 at 10:09 PM ·
texturemovietexture
Movie Texture not updating
I am trying to play a few movies in succession but they don't seem to be updating the texture. I am able to play scanLoop but when I try to change to login, scanLoop stops but does not change to the other movie texture. Am I supposed to update textures differently? I have tried SetTexture() and trying to change material.mainTexture = newTexture.
I should mention that if I comment out the first yield return, it does play the movie login movie.
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class videoPlayer : MonoBehaviour {
public MovieTexture scanLoop;
public MovieTexture login;
public MovieTexture Mask;
// Use this for initialization
void Start () {
GetComponent<Image>().material.mainTexture = scanLoop as MovieTexture;
scanLoop.Play();
scanLoop.loop = true;
StartCoroutine(VideoHandler());
}
IEnumerator VideoHandler()
{
yield return new WaitForSeconds(5f);
PlayLogin();
}
public void PlayLogin()
{
scanLoop.loop = false;
GetComponent<Image>().material.SetTexture("_MainTex", login as MovieTexture);
login.Play();
}
public void PlayMask()
{
GetComponent<Image>().material.mainTexture = Mask as MovieTexture;
Mask.Play();
}
}
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612071842im_/https://answers.unity.com/themes/thub/images/avi.jpg)