Search Unity

Creating Asset Bundle of StreamingAssets

Discussion in 'Scripting' started by matrix211v1, Feb 29, 2012.

  1. matrix211v1

    matrix211v1

    Joined:
    Jan 20, 2009
    Posts:
    193
    Hello All!

    How can one create a Asset Bundle of StreamingAssets? I am trying to do it for an iOS and Android because I "cannot" have it part of the APK/IPA due to the size limit over 3G.

    I have tried to use:

    Code (csharp):
    1. BuildPipeline.BuildAssetBundle(Selection.activeObject, Selection.objects, path, BuildAssetBundleOptions.CompleteAssets, BuildTarget.Android);
    But I get the error "'MovieTexture' is not supported when building for Android."

    Of course, all 80mb of my StreamingAssets are the Movies in .MP4 format, which I wanted to download as an assetbundle and cache it on the device.

    Any thoughts?

    Thanks!
     
  2. matrix211v1

    matrix211v1

    Joined:
    Jan 20, 2009
    Posts:
    193
    Anyone?
     
  3. vguruv

    vguruv

    Joined:
    Jul 8, 2008
    Posts:
    6
    I am able to build the assetbundle from the StreamingAssets folder when the Build Settings platform is set to something other than Android.
    (The assetbundle still targets Android)

    Problem is the video in the assetbundle is not streaming...
     
  4. timsk

    timsk

    Joined:
    May 27, 2011
    Posts:
    177
    Has anyone found a way to build a bundle containing video files to a mobile device?

    We are using MobileMovieTexture to play our videos, but don't want the videos bloating the app size. So we would like to build them to a bundle, then download them over the web at runtime.

    I'm assuming there is a way to do this? Would seem an unnecessary limitation if Unity disallows video files in mobile asset bundles.
     
  5. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    timsk you are missinterpreting the situation or don't seem to understand what StreamingAssets actually does.


    You can not include video files for mobiles.
    As the error says, movie textures are not supported on mobile and the only thing Asset Bundles can contain are Unity Asset objects. This is what MovieTexture is, but a file in StreamingAssets isn't. Unity can and will not transport anything but its known asset types through AssetBundles (as its name implies)


    Thats why StreamingAssets was brought into the mix.
    StreamingAssets does copy over your movie 1 : 1 as added, its not touched by Unity in any form and especially not 'removed as file and integrated into the assets', which would happen with Asset Bundle data for example.
    The movie playback that happens on the device requires the file to be present as file so the iOS / Android movie player can use them, Unity gives you no movie playback capabilities at all on its own, it only offers you what the OS offers I fear. MobileMovieTexture has this very limitation as well as they rely on the movie playback hardware support, otherwise your game would run at 5fps.

    What you can do is not include the movie in the build and download it later.
    But for that you don't need AssetBundles.
    You can just put the file online, download it with WWW and then use System.IO.WriteAllBytes(www.bytes,Application.persistentDataPath + "/MyCoolMovie.mp4"); to store it and reference it by that path later on.
     
  6. timsk

    timsk

    Joined:
    May 27, 2011
    Posts:
    177
    Thanks for the help Dreamora.

    I understand I could just download the file and use IO to store it, but we are planning on using quite a few videos and it would be handy to be able to use AssetBundles, as we do with all our other assets. Rather than have to create a separate system for just video assets.

    I suppose the clue is in the name AssetBundle :). What I want is a FileBundle. Time to look into compression methods then!
     
    Last edited: Nov 28, 2012