Quantcast
Channel: Questions in topic: "webgl"
Viewing all articles
Browse latest Browse all 2390

unity webgl movie texture on mobile

$
0
0
I am able to play videos in webgl build inside of the Canvas UI using the temporary solution made by unity in the asset store The thing is, on mobile it does not work, i only get a gray screen is there any way to do it? this is my code for playing video in webgl using UnityEngine; using System.Collections; using System.Runtime.InteropServices; using UnityEngine.UI; public class CanvasVideo : MonoBehaviour { private WebGLMovieTexture Vtex; public bool IsReady { get{ return Vtex.isReady; } } public GameObject rImage; private const string path = "StreamingAssets/"; public string currentVideo = ""; public bool onStart = false; public bool loop = false; public bool play = false; void Start () { //rImage.GetComponent().material = new Material (Shader.Find("Diffuse")); if (onStart && currentVideo != "") { loadVideo (currentVideo); playVideo (loop); } //StartCoroutine (vidUpdate ()); } public void loadVideo(string vid) { Vtex = new WebGLMovieTexture(path + vid); rImage.GetComponent().material.mainTexture = Vtex; } public void playVideo(bool looping) { loop = looping; Vtex.loop = loop; StartCoroutine (vidUpdate ()); } private IEnumerator vidUpdate() { Vtex.Play (); play = true; yield return new WaitUntil (() => Vtex.isReady); while (play) { Vtex.Update (); yield return null; } } }

Viewing all articles
Browse latest Browse all 2390

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>