Search Unity

Video VideoClip.originalPath AssetBundle Unload issues

Discussion in 'Audio & Video' started by SkyshipGames, Sep 27, 2019.

  1. SkyshipGames

    SkyshipGames

    Joined:
    Sep 27, 2019
    Posts:
    4
    I'm working on a suite of games using the beta feature of Unity as a Library (UaaL) Many of these games come with asset bundles that contain VideoClip(s) in them.

    The problem I am having, is that when you exit one of these games to return to the host app, then try to re-enter that game, the Asset Bundle loader will throw an exception because the asset bundle has already been loaded.

    Researching this, I found that it was best to unload bundles as soon as you have finished referencing them, to avoid this problem. So for most objects I load the bundle, instantiate the object, unload the bundle.

    However, I am having difficulty with Videoclips, because it seems the VideoClip is itself not a true asset reference to the video file, and relies on the VideoClip.originalPath to point towards the resource the clip is loaded from. When I unload the bundle, the originalPath now points to nothing and the video will not load when setup in a VideoPlayer.

    I had hoped instantiating the VideoClip, to clone it, would also duplicate the originalPath, but it does not.

    Given this context, my specific question is; how can one access the true video file referenced by the originalPath, clone that, and then create a VideoClip that points to that path. In this way, allowing me to unload the bundle immediately after it has been loaded and referenced.

    Thank you.



    EDIT:
    For anyone stuck on the same problem. I still haven't gotten a solution, but I have a workaround that may help. I've been tracking the assetbundles I load by their name (AssetBundle.name), and then whenever loading a new game, I unload all of those tracked bundles. I do this by using AssetBundles.GetAllLoadedBundles() then comparing the names of those bundles to the names of those in my list. I do it in this way because referring to the actual AssetBundle component was causing me problems, when using Unity as a Library (UaaL). The AssetBundle component would lose serialization between games, but a List<string> could be maintained. It's not great that the AssetBundle has to remain fully loaded through all playtime, but it's working.
     
    Last edited: Sep 30, 2019
  2. unity_qV-9y6iajfqzew

    unity_qV-9y6iajfqzew

    Joined:
    Nov 12, 2020
    Posts:
    1
    Yes, I also have a same problem, it seems that problem with only videoclips only. Other assets like audio and images which got from same assetbundle, perfoming good.