ViveMediaDecoder icon indicating copy to clipboard operation
ViveMediaDecoder copied to clipboard

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

Open ghost opened this issue 9 years ago • 1 comments

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

ghost avatar Oct 09 '17 05:10 ghost

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.

DameonL avatar Oct 16 '17 17:10 DameonL