Forum rules - please read before posting.

Playing videos in the ActionList Editor using Unity's new VideoPlayer component?

Hi all
I'm new to AC, working on a 3D game that uses FMV style video assets for conversations. In Engine: Play Movie Clip it only gives the option to use a movie texture, but I'd like to use Unity's new VideoPlayer component instead because it allows for processing video clips a different way that maintains their transparency. Any advice on how to best do this?
Thanks!

Comments

  • edited April 2017
    Hi, and welcome to the Adventure Creator forums @clairesquare

    Well, I must say you got me a bit with this one, because I have never used the new VideoPlayer Component yet. I'm not aware of AC using this component in any actions yet. As this is a new component, chances are we'll be getting an updated action to use it later on. For now, I'll try to do a bit of research and see what can be done, though at this point a custom action might be needed to control the component. I'm going to take a look at Unity's API regarding the VideoPlayer component to try to get an idea how hard or easy it'll be to make such custom action.
  • Alright, here's a quick wip custom action to control your video players. Give it a try and tell me how it goes. 
  • Wow @Alverik thank you! A big part of the reason I'm using AC is because I'm terrible at programming. Thank you for writing a custom script for me!

    I took all the code you wrote and put it in "ActionManageVideoPlayer.cs" script file inside AdventureCreator/Scripts/Actions folder. But how do I access that action from the Action List Editor? I couldn't find it added to any of the dropdown menus including "Custom"

    Thank you!
  • In case its helpful to figuring it out - these are the error messages I'm getting when I go the Actions Manager in the AC Game Editor and click on "Custom." I'm only using the VideoPlayer with Render Textures so maybe I could comment out the CameraBackPlane and FrontPlane parts?

    Instance of ActionManageVideoPlayer couldn't be created. The the script class needs to derive from ScriptableObject.
    UnityEngine.ScriptableObject:CreateInstance(String)
    AC.AdventureCreator:RefreshActions() (at Assets/AdventureCreator/Scripts/Managers/Editor/AdventureCreator.cs:464)
    AC.AdventureCreator:OnGUI() (at Assets/AdventureCreator/Scripts/Managers/Editor/AdventureCreator.cs:309)
    UnityEditor.DockArea:OnGUI()

    Assets/AdventureCreator/Scripts/Actions/ActionManageVideoPlayer.cs(101,26): error CS0117: `UnityEngine.Video.VideoRenderMode' does not contain a definition for `CameraBackPlane'

    Assets/AdventureCreator/Scripts/Actions/ActionManageVideoPlayer.cs(102,26): error CS0117: `UnityEngine.Video.VideoRenderMode' does not contain a definition for `CameraFrontPlane'

    Assets/AdventureCreator/Scripts/Actions/ActionManageVideoPlayer.cs(202,26): error CS0117: `UnityEngine.Video.VideoRenderMode' does not contain a definition for `CameraBackPlane'

    Assets/AdventureCreator/Scripts/Actions/ActionManageVideoPlayer.cs(203,26): error CS0117: `UnityEngine.Video.VideoRenderMode' does not contain a definition for `CameraFrontPlane'



  • edited April 2017
    What Unity version are you using? I used a beta version of Unity 5.6 when I created the custom action, which is the one I currently have installed (the previous Timeline preview build), so there may be changes if you are using a newer Unity version (also, the action won't work on Unity 5.5 since the video player doesn't exist in that one). They may have changed some field names. Anyway, I'll double check the API or get a new version of Unity to verify. But in the meantime you can go ahead and try to just comment out the related code.

    PS: Actually, this error feels familiar. Just in case make sure the code ends with the proper amount of } symbols (it may be that you are missing one). It should end like so:

    }  
    }
      }
  • edited April 2017
    Ok, so they did change the names of those two enum members. Rename them to CameraFarPlane (instead of Back) and CameraNearPlane (instead of Front).

    PS: I've updated the code in the wikia. Also added some code to make sure the script doesn't cause warnings in Unity 5.5 and lower (for those of us that like to keep all custom actions in a single folder, to easily copy paste no matter the project or Unity version, heh).
  • It worked!!!! Thank you so much @alverik !!
  • @alverik Thanks again for making this custom action that works with the video player! 

    How do I set it so that it will play the entire video clip before "After running: Action to skip to" ? If I set the "After Running" to "Stop" it will play the video full clip and then stop, but if I set it to "After Running: Continue" or "After running: Action to skip to" so I can have another action afterwards it just skips ahead to the next action right away.

    Thank you!
  • edited May 2017
    clairesquare  It didn't have that option. You could have done that effect, more or less, by using an engine wait right after the action, but I've added it as an option. I can't say if it works correctly though, because I haven't tested it. But right now it'll give you an option to wait, and by default the wait time will be the Clip's duration. You can define a custom wait time too (which in essence is not that different from the Engine wait action). 

    Though, I'm not sure if it'll work right, I'm not sure if the VideoPlayer's clip field has any requirements (seeing how you can have so many different ways to display the video), so just try it, if it does'nt wait the correct time, try inputting the wait time manually (but be ware, that AC/Unity will probably not wait in realtime, but deltaTime, so you may have to add some extra seconds to actually get next action to run when the video has actually ended).

    Anyway, the updated code is in the same link as above.

    PS:If you want to add an offset to the clips wait time you can add some extra time to the following line:

    if(UseWaitTime) playTime = (float)_videoPlayer.clip.length;

    like so:

    if(UseWaitTime) playTime = (float)_videoPlayer.clip.length + 1f;
  • Oh man @alverik you are amazing!!! I did think about adding a custom engine wait time but since I have over a hundred video clips to play putting in the exact length of each one seemed like quite a process. The new "Wait until finished" checkbox you added seems like it is totally working so far! 

    thank you thank you thank you!!!
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.