void Start() { materialEffect = GetComponent<Renderer>().material; var url = "file://" + Application.dataPath + "/StreamingAssets/Back To The Futur.ogg"; var www = new WWW(url); movieTexture = (MovieTexture)www.movie; movieTexture.loop = true; movieTexture.Play(); UnityEngine.Shader.SetGlobalTexture("_SamplerVideo", movieTexture); }
public void SetTexture2D(MovieTexture tex) { this.oggTexture = tex; renderer.material.SetTexture("_MainTex", tex); // In order to get texture size, we have to play the texture for one frame. // this is a known bug in unity. // http://forum.unity3d.com/threads/71220-get-MovieTexture-resolution tex.Play(); tex.Pause(); tex.loop = this.isLooping; this.textureAspectRatio = (float)tex.width / tex.height; }
// Use this for initialization void Start() { movieTexture = mat.mainTexture as MovieTexture; movieTexture.loop = true; movieTexture.Play(); }