I boys I’m trying to download a video from the web and I’m using this code:
var url = "myfileinmylink";
function Start () {
// Start a download of the given URL
var www : WWW = new WWW (url);
// Wait for download to complete
yield www;
Debug.Log ("downloaded");
// assign texture
renderer.material.mainTexture = www.texture;
renderer.material.mainTexture.Play();
}
When video is downloaded, instead of the video, appairs a red question mark!
Where am I mistaking?
I found this script that show a video into a Gui object! Can you help modify it in way to show the video on a object? (movie texture)
var url = "http://www.unity3d.com/webplayers/Movie/sample.ogg";
function Start () {
// Start download
var www = new WWW(url);
// Make sure the movie is ready to start before we start playing
var movieTexture = www.movie;
while (!movieTexture.isReadyToPlay)
yield;
// Initialize gui texture to be 1:1 resolution centered on screen
guiTexture.texture = movieTexture;
transform.localScale = Vector3 (0,0,0);
transform.position = Vector3 (0.5,0.5,0);
guiTexture.pixelInset.xMin = -movieTexture.width / 2;
guiTexture.pixelInset.xMax = movieTexture.width / 2;
guiTexture.pixelInset.yMin = -movieTexture.height / 2;
guiTexture.pixelInset.yMax = movieTexture.height / 2;
// Assign clip to audio source
// Sync playback with audio
audio.clip = movieTexture.audioClip;
// Play both movie sound
movieTexture.Play();
audio.Play();
}
Thanks!
hiiii, i m using it…but instead of coming on a plane…its coming like a 2d plane on the player screen and not on texture …is it same that is happening to you ??
if things r working fine then please export as package and mail me at ersaurabh101@gmail.com
this last script il create to watch a video trought a guiTexture! I want watch the video on a cube for example!
I think I need merge in some way the two scripts in this page but I don’t know how!
if u know, please do mail me, do u know script to load text from any url ?
Solved
var url = "http://www.unity3d.com/webplayers/Movie/sample.ogg";
@script RequireComponent (AudioSource)
function Start ()
{
var www = new WWW (url);
var movieTexture = www.movie;
while (!movieTexture.isReadyToPlay)
yield;
renderer.material.mainTexture = movieTexture;
audio.clip = movieTexture.audioClip;
movieTexture.Play ();
audio.Play ();
}
Thanks to RingOfStorms and Appels