MovieTexture not playing in playmode
I can't seem to load in a movietexture from file, attach it as a movietexture to a prefab instance (created via script upon opening of Unity), and play it in edit mode. I can do two things: 1) I can get the texture to play in edit mode. The movie I'm importing is already in ogv format. So I simply am able to attach it to the prefab and play the texture, triggered by my script. However, this is all done in edit mode, not play mode 2) I can import the texture as an mp4 movie texture and assign it as a texture to my prefab. In this case, I can not get it to play in edit mode and when I enter play mode, I get the following error
LoadMoveData got NULL! UnityEngine.MovieTexture:Play()
However, my movie is already imported into the project as an asset so it should not be null.
Can anyone assess the issue?? My code is as follows:
using UnityEditor; using UnityEngine; using System.Collections;
[ExecuteInEditMode] class MyEditorScript : MonoBehaviour {
static void Start()
{
if (Application.isPlaying)
return;
Debug.Log ("Test");
Vector3 position = new Vector3(0, 0, 0);
Vector3 scale = new Vector3 (10, 10, 10);
GameObject newSphere = (GameObject)Instantiate (Resources.Load("360 Video Player"));
newSphere.name = "360 Video Player";
newSphere.transform.position = position;
newSphere.transform.localScale = scale;
WWW diskTex = new WWW ("file:///C:\\...\\Video.ogv");
MovieTexture tex1 = diskTex.movie;
while (!tex1.isReadyToPlay) {
}
MovieBehaviorScript mov = newSphere.GetComponent<MovieBehaviorScript> ();
mov.movTexture = tex1;
Renderer ren = newSphere.GetComponent<Renderer>();
ren.sharedMaterial.mainTexture = tex1;
UnityEditor.EditorApplication.ExecuteMenuItem("Edit/Play");
tex1.Play ();
}
}
Your answer
Follow this Question
Related Questions
Issues with video player coroutine 2 Answers
Whenever I try to enter playmode after creating a script, a compiler error pops up 0 Answers
Unity Collab breaks Play Mode 0 Answers
C# Scripts Error 1 Answer
Scrpits component disappears when I enter playmode 0 Answers