Search Unity

  1. Unity 2020.1 has been released.
    Dismiss Notice
  2. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Help Wanted UnityEngine.Video Script not working

Discussion in 'Audio & Video' started by benbeart, Jun 8, 2020.

  1. benbeart

    benbeart

    Joined:
    Apr 4, 2020
    Posts:
    2
    Hi, please see screenshot of code.

    I've got some video clips that load into an array correctly but i can't figure out why, even with UnityEngine.Video enabled, there is a compiler error with:

    videoPlayer.Play();

    I can't seem to access any VideoPlayer scripting functionality - please can you help correct what i've done wrong?

    thanks

    ben
     

    Attached Files:

  2. xazz_6_unity

    xazz_6_unity

    Joined:
    Jun 19, 2020
    Posts:
    2
    I'm still getting the same error unfortunately.. I even tried on a new script and without any editing, I tried to attach to an empty gameobject and the error still popped up... Any suggestions? Thank you.
    Kodi nox
     
    Last edited: Jun 20, 2020
  3. benbeart

    benbeart

    Joined:
    Apr 4, 2020
    Posts:
    2
    Hi xazz, I haven’t found a solution anywhere as to why using UnityEngine.Video does not allow the scripting of video player specific commands.
    So I’ve found workarounds I’ll share.

    If you create a ‘button’ game object and assign the game object with the video player to the ‘button’ -> ‘on click’ function and runtime, there is an option there to VideoPlayer.Play();

    It does overcome my problem where I wanted a script to change the videoclips from an array (of 100 MP3’s) and the commands don’t work. So instead, I’ve created a large number of empty gameobjects. Added a video player component to each of them with the individual video clips attached to them.

    I then coded a script to allow the original button to change which game object was active and then ‘Invoke’ the videoplayer that starts the video.

    does that make sense?

    i was quite chuffed to find that long winded workaround that works 100% with there being no literature in recent months on the video player.
     
  4. ShemusD1

    ShemusD1

    Joined:
    Jul 30, 2020
    Posts:
    1
    Thank you for suggestions
     
unityunity