unity3d - Unity Video script not playing sound -
im using plugin unity asset store , trying video playing sound - not. here script plays video --
using unityengine; using unityengine.video; namespace complete360tour { [addcomponentmenu("complete360tour/media/videomediareactor")] public class videomediareactor : monobehaviour, imediaswitchreactor<videomedianodedata> { //----------------------------------------------------------------------------------------- // inspector variables: //----------------------------------------------------------------------------------------- [header("assignment")] [serializefield] protected mediaview mediaview; [serializefield] protected videoplayer videoplayer; //----------------------------------------------------------------------------------------- // private fields: //----------------------------------------------------------------------------------------- private rendertexture rendertexture; //----------------------------------------------------------------------------------------- // unity lifecycle: //----------------------------------------------------------------------------------------- protected void awake() { if (mediaview == null) debug.logwarning("no mediaview assigned. please assign mediaview."); } //----------------------------------------------------------------------------------------- // public methods: //----------------------------------------------------------------------------------------- public void switchmedia(videomedianodedata data, mediaswitchstates state) { if (data == null) { invalidswitchdata(); return; } switch (state) { case mediaswitchstates.beforeswitch: break; case mediaswitchstates.switch: beginvideo(data.videoclip); mediaview.setstereoscopic(data.isstereo); break; case mediaswitchstates.afterswitch: break; } } public void exitmedia() { invalidswitchdata(); } //----------------------------------------------------------------------------------------- // private methods: //----------------------------------------------------------------------------------------- private void invalidswitchdata() { videoplayer.stop(); videoplayer.targettexture = null; mediaview.setmedia(null); mediaview.setstereoscopic(false); } private void beginvideo(videoclip videoclip) { rendertexture = new rendertexture((int) videoclip.width, (int) videoclip.height, 0); videoplayer.clip = videoclip; videoplayer.targettexture = rendertexture; mediaview.setmedia(rendertexture); videoplayer.play(); } } }
i tried adding audio stuff following
http://justcode.me/unity2d/how-to-play-videos-on-unity-using-new-videoplayer/
but no luck. audio still wouldn't play.
Comments
Post a Comment