- Home /
Question by
Graf-Zorba · Apr 27, 2015 at 01:03 AM ·
guiwwwienumeratormovietexturemovie
www.movie on GUI Texture in front of Camera
I am trying to adjust the www.Movie script so that the movie gets projected on a full screen GUI always appearing in front of the current camera position. The default code on http://docs.unity3d.com/ScriptReference/MovieTexture-audioClip.html sets the camera position back to the origin. Im also looking for a way to prematurely end the projection on Click.
In the code below I attempt to draw a temporary GUI texture, it seems almost working but not quite. Anyone pointing me in the right direction has my eternal gratitude ...
using UnityEngine;
using System.Collections;
//[RequireComponent(typeof(GUITexture))]
//[RequireComponent(typeof(AudioSource))]
public class GUI_Test4 : MonoBehaviour {
public string url;
IEnumerator Start() {
WWW www = new WWW(url);
MovieTexture movieTexture = www.movie;
while (!movieTexture.isReadyToPlay) {
yield return null;
}
GUITexture gt = GetComponent<GUITexture>();
gt.texture = movieTexture;
GUI.DrawTexture(new Rect(0, 0, Screen.width, Screen.height), movieTexture, ScaleMode.ScaleToFit, true, 0F);
/*
transform.localScale = new Vector3(0, 0, 0);
transform.position = new Vector3(0.5F, 0.5F, 0);
Rect inset = gt.pixelInset;
inset.xMin = -movieTexture.width / 2;
inset.xMax = movieTexture.width / 2;
inset.yMin = -movieTexture.height / 2;
inset.yMax = movieTexture.height / 2;
gt.pixelInset = inset;
*/
AudioSource aud = GetComponent<AudioSource>();
aud.clip = movieTexture.audioClip;
movieTexture.Play();
aud.Play();
}
}
Comment
Your answer
Follow this Question
Related Questions
'movie' is not a member of 'UnityEngine.WWW' 1 Answer
MovieTexture stops playing after first frame 0 Answers
Problem streaming large movie 1 Answer
www.movie.other formats 1 Answer
WWW.movie doesn't work 1 Answer