I try to put my words into code,
In short, guiTexture is recognized as movTexture in function start part, but not in the OnGUI part…
There is also a package containing scene at the end…
Thanks to all responders…
var url = "http://www.digimed.com.tr/fuarassets/video/ardex.ogg";
var mygui : GUITexture;
mygui = GetComponent (GUITexture);
var bgr : GUITexture;
var btn0 : GUITexture;
var btn1 : GUITexture;
var btn2 : GUITexture;
var btn3 : GUITexture;
var btn4 : GUITexture;
var btn5 : GUITexture;
mygui.enabled = true;
bgr.enabled = true;
btn0.enabled = true;
btn1.enabled = true;
btn2.enabled = true;
btn3.enabled = true;
btn4.enabled = true;
btn5.enabled = true;
function Start () {
var www = new WWW(url);
var movTexture = www.movie;
while (!movTexture.isReadyToPlay)
yield;
mygui.mainTexture = movTexture;
// this was, guiTexture.texture = movieTexture;
// I just change it to play my video at where I want.
audio.clip = movTexture.audioClip;
movTexture.Play();
// Here I am very confused... When I disable function OnGUI part
// below, it works. But now it gives this error:
// NullReferenceException: Object reference not set to an instance of an object
audio.Play();
}
@script RequireComponent (GUITexture)
@script RequireComponent (AudioSource)
function OnGUI() {
if(btn2){
if (mygui.mainTexture.isPlaying) {
mygui.mainTexture.Pause();
btn2 = btn1;
}
else {
mygui.mainTexture.Play();
btn2 = btn0;
}
}
if(btn3){
mygui.mainTexture.Stop();
btn2 = btn1;
}
if(btn4){
mygui.mainTexture.Stop();
btn2 = btn1;
}
if(btn5){
mygui.mainTexture.Stop();
mygui.enabled = false;
bgr.enabled = false;
btn0.enabled = false;
btn1.enabled = false;
btn2.enabled = false;
btn3.enabled = false;
btn4.enabled = false;
btn5.enabled = false;
}
}
// I tried almost every possible combination, but my scene
// doesnt like this OnGUI stuff :)
1076116–40187–$webvideo_w_controller_try2.unitypackage (41.8 KB)