ViveSoftware / ViveMediaDecoder

A high performance video decoding Unity plugin for Windows.
http://u3d.as/usf
Other
129 stars 36 forks source link

Can this be made to work with Unity uGUI in addition to Mesh #9

Open ghost opened 6 years ago

ghost commented 6 years ago

Hi I am trying to figure out how to play a video on a uGUI canvas/texture?

DameonL commented 6 years ago

Replace this function on line 416: private void setTextures(Texture ytex, Texture utex, Texture vtex) { Material texMaterial = GetComponent<MeshRenderer>().material; texMaterial.SetTexture("_YTex", ytex); texMaterial.SetTexture("_UTex", utex); texMaterial.SetTexture("_VTex", vtex); } With this: private void setTextures(Texture ytex, Texture utex, Texture vtex) { Material texMaterial = null; if (GetComponent<Image>() != null) texMaterial = GetComponent<Image>().material; if (texMaterial == null) texMaterial = GetComponent<MeshRenderer>().material; texMaterial.SetTexture("_YTex", ytex); texMaterial.SetTexture("_UTex", utex); texMaterial.SetTexture("_VTex", vtex); } Then remove the RequireComponent(typeof(MeshRenderer)) attribute from the Decoder class. You can now attach the decoder to an Image instead of a MeshRenderer.