For a school project we are trying to make an interactive video. The character is supposed to have a video that loops (easy enough to make) but once a button is pressed it has to switch to another movie and afterwards back to the loop. I am working with MovieTextures but I can’t load another Movietexture on the object to replace the loop, if anyone could help with that, I’d really appreciate it. Also if someone knows how to apply a random movietexture to the object, that would be SUPERB.
Here’s my code:
using UnityEngine;
using System.Collections;
public class NewBehaviourScript : MonoBehaviour {
public MovieTexture movie;
public MovieTexture [] Like;
public MovieTexture [] OLikes;
public MovieTexture [] Dislike;
public MovieTexture [] ODislike;
void Start () {
Renderer r = GetComponent<Renderer>();
MovieTexture movie = (MovieTexture)r.material.mainTexture;
movie.Play();
movie.loop = true;
}
// Update is called once per frame
void Update () {
if (Input.GetKeyDown (KeyCode.L))
{
movie.loop = false;
movie.Stop();
renderer.material.SetTexture ("_MainTex", Like[Random.Range(0, Like.Length)]);
// Tried getting the texture from the list, didn't work.
movie = Like[Random.Range(0,Like.Length)];
// Another way I tried to get an item from the list
movie.Play();
}
}
}
The lists are filled in the inspector.
I tried adding a second public MovieTexture just filled it in in the inspector but I couldn’t get the texture to change.
ANY HELP, EVEN THE SIMPLEST CODE CAN GET ME A LITTLE FURTHER. IT’S ALL REALLY APPRECIATED.