Hiya.
Im currently trying to play a video on a piece of geometry.
I have a video player, a movie in the StreamingAssets folder.
At Start I create a new RenderTexture, link the movie, and assing it to the Video player.
In the editor it works as expected. But once compiled and on a browser I just get a locked frame.
Im not sure if Im missing something:
public class VideoLink : MonoBehaviour
{
public VideoPlayer myVideoPlayer = null;
public string myVideo = "myVideoGoesHere.mp4";
public bool playOnAwake = false; //These get set in the editor as needed
public bool looping = false; //These get set in the editor as needed
public bool play = false; //These get set in the editor as needed
public Material myEnvMaterial = null; // This is the material on my geo
public RenderTexture myRenderTexture = null; // This will point to the generated rendeer texture
public int X = 1024 ; //X res
public int Y = 512 ; //Y Res
// Start is called before the first frame update
void Start()
{
myVideoPlayer.playOnAwake = playOnAwake;
myVideoPlayer.isLooping = looping;
myVideoPlayer.renderMode = UnityEngine.Video.VideoRenderMode.RenderTexture;
if (!myRenderTexture){
myRenderTexture = new RenderTexture (X,Y,24);
myEnvMaterial.SetTexture("_MainTex", myRenderTexture);
}
myVideoPlayer.url = System.IO.Path.Combine (Application.streamingAssetsPath, myVideo);
myVideoPlayer.targetTexture = myRenderTexture;
myVideoPlayer.Prepare();
if (play){
myVideoPlayer.Play();
}
}
Any help will be appreciated
-P
