Hi there im trying to see if there is a way to change this script to support movie textures instead if so im i going the right way about it
public var soundClips : AudioClip[];
private var musicNumber:int = 0;
private var playNextMusic:boolean = true;
// Play default sound
function Update ()
{
if(Input.GetKey("m")) {
if (playNextMusic) PlayTheNextMusic();
}
}
function PlayTheNextMusic() {
playNextMusic = false;
audio.clip = soundClips[musicNumber];
audio.Play();
yield WaitForSeconds (audio.clip.length);
playNextMusic = true;
++musicNumber;
if (musicNumber == AudioClip.Length) musicNumber = 0; // I'm not sure if it is Length or length here...
}
var originalWidth = 960.0; // define here the original resolution
var originalHeight = 600.0; // you used to create the GUI contents
private var scale: Vector3;
var Play : GUIStyle;
var Stop : GUIStyle;
var Next : GUIStyle;
var Audio: AudioClip;
var movTexture : MovieTexture[];
private var movieNumber : int = 0;
private var PlayNextMovie : boolean = true;
function OnGUI ()
{
scale.x = Screen.width/originalWidth; // calculate hor scale
scale.y = Screen.height/originalHeight; // calculate vert scale
scale.z = 1;
var svMat = GUI.matrix; // save current matrix
// substitute matrix - only scale is altered from standard
GUI.matrix = Matrix4x4.TRS(Vector3.zero, Quaternion.identity, scale);
GUI.matrix = Matrix4x4.TRS(Vector3.zero, Quaternion.identity, scale);
GUI.BeginGroup (Rect (670,420,400,100),"");
GUI.Box(Rect(0,0,230,90), "");
if ( GUI.Button(Rect (10,0,100,100), "" ,Play))
{
movTexture.Stop();
audio.Play();
}
if (GUI.Button(Rect( 120,0,100,100),"",Stop))
{
movTexture.Stop();
audio.Stop();
}
if (GUI.Button(Rect(240,0,100,100),"Next",Next))
{
if (playNextMusic) PlayTheNextMusic();
if(PlayNextMovie) PlayTheNextMovie();
}
GUI.EndGroup();
// restore matrix before returning
GUI.matrix = svMat; // restore matrix
}
function PlayTheNextMovie () {
playNextMovie = false;
movieTexture = movTexture[movieNumber];
renderer.material.mainTexture = movTexture;
movTexture.Play();
yield WaitForSeconds (movieTexture.length);
playNextMovie = true;
++movieNumber;
if (movieNumber == MovieTexture.Length) movieNumber = 0;
}