Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Assert bundles in the data folder

Discussion in 'Android' started by ritchparker, Oct 29, 2010.

  1. ritchparker

    ritchparker

    Joined:
    Apr 9, 2008
    Posts:
    26
    Hello,

    Does anyone know how to add items to the apk, pre or post build? I need to add asset bundles to the package and load them later at runtime. Does the Application.dataPath point to the package on the Android?
     
  2. BuzzJive_Legacy

    BuzzJive_Legacy

    Joined:
    Oct 11, 2010
    Posts:
    26
    The way I've gone about it is to decompose the apk using apktool, add the assets I need, then repackaging the apk with apktool (but you will need to sign it again on your own afterwards before you can install it - unity does that for you). It's not pretty, but it works.
     
  3. Wozik

    Wozik

    Joined:
    Apr 10, 2009
    Posts:
    662
    Just create the folder StreamingAssets in your project, but all the stuff you need and it all will be packed to the apk and will be deployed into app directory on the device
     
  4. ritchparker

    ritchparker

    Joined:
    Apr 9, 2008
    Posts:
    26
    Hello, Thanks for the info ... But how do I load the bundles from this location?
     
  5. eriQue

    eriQue

    Unity Technologies

    Joined:
    May 25, 2010
    Posts:
    595
    With pre 3.2 I guess you don't. With 3.2 you can use something like WWW("jar:file://" + Application.dataPath + "!/assets/<yourbundlename>");, if <yourbundlename> is under Assets/StreamingAssets.
     
    Last edited: Sep 2, 2011
  6. AShim

    AShim

    Joined:
    Sep 24, 2009
    Posts:
    8
    Correction:
    var www: WWW = new WWW("jar:file://" + Application.dataPath + "!/assets/<file_name>");
    yield www; // loading
    guiTexture.texture = www.texture;
     
  7. agreen

    agreen

    Joined:
    Jul 13, 2011
    Posts:
    23
    hmm I'm still having trouble loading from that path, i've actually checke the .apk file and it does have the correct files in the assets folder.
     
    Last edited: Aug 11, 2011
  8. eriQue

    eriQue

    Unity Technologies

    Joined:
    May 25, 2010
    Posts:
    595
    Does the logcat give any additional hints?
     
  9. gonglei007

    gonglei007

    Joined:
    Oct 10, 2012
    Posts:
    2
    When building assets bundle (BuildPipeline.BuildAssetBundle), don't forget add "BuildTarget.Android" paramater, or the data will not be loaded even the path is correct.