Add different data to apk

Hi,

How do i include a file or material, which is not used by default in my scene, but is supposed to be used defending on a script, into a apk?

I tried to unpack the apk with the apktool (Google Code Archive - Long-term storage for Google Code Project Hosting.), but apperently the files and path structure are changed by unity. Therefore i dont know if this will work. I did not try it yet, because my little android is broken atm.

thx in advance

I have a similar issue. I need to be able to add a few asset bundles to the Data folder prior to the APK being created (or during the process at the very least). This is no problem on iOS, because I just have it build the XCode project and then manually copy the files into the Data folder and compile. With Android it’s all one un-interruptable process, so I guess I need a PostBuild script or something, but I’m not sure how to do that.

What about StreamingAssets which end up in the build untouched on mobiles?

Not sure what you mean, Dreamora. I’m assuming you’re referring to streaming asset bundles, which is what I’m using, referenced here:
http://unity3d.com/support/documentation/Manual/Loading%20Resources%20at%20Runtime.html

Unfortunately, this page doesn’t describe how you’re supposed to be able to include said bundles with your app. I may eventually have the game load in content dynamically, but for right now I want the app to ship with these files in the data folder just like the iOS version. There’s bound to be something I’m missing in this process.

Ah, I’ve found references now to the StreamingAssets folder. I’m going to give that a try. I’ll post with my results. Thanks!

Just for others struggling about: StreamingAssets is a special folder - the only docs reference to it I’m aware of is related to the movies on mobile devices, but it works for everything, not just movies. movies are just the only inbuilt feature making use of it

Hi sry for reopening after 2 weeks. My projects fell a bit asleep until now.

Still this is not clear to me how this works and what i have to do. I read the link Kake posted and searched for the topic of “streaming assets” which dreamora mentioned.

I have tried the first way and build a bundle with my assets. But here i am stuck again. In my understanding this created bundle is not included in my apk by default. Therefore i dont know how to access it. Worse, as i unterstand, the command “AssetBundle.Load” has no argument for a path. How can i access a bundle? Or are these always included? …I think i got this wrong

“Streaming assets” on the other hand are totally unknown to my. The two pages i gave me no clue if this is a possible way to go. In Forum and in the Doku

I believe my main problem is not the fact, that i dont know how to include the files, but how the android file system works. In the following i try to describe what i have done and what i want to do:
I plug my devise as usb mass storage to my pc. Then i put my assets and my apk in a folder under the root( i think…) something like /root/data/…
In my apk i try to load the assets with LoadAssetAtPath(“root/data/123.png”, typof(Texture));. How ever this files cannot be found.

Can anyone help me with this problem? I think I need an explantion at basic level.:frowning:

You can revise thoroughly the Character Customization demo, http://unity3d.com/support/resources/example-projects/charactercustomization, for a complete example of Asset Bundles, but in short what you have to do is to create a WWW pointing to the assetbundle. The WWW supports protocols like http for web access and file for local access. If you want local access, just store the assetbundles in the StreamingAssets folder and point your WWW to : “jar:file://” + Application.dataPath + “!/assets/name.assetbundle”. You have to yield until the WWW is loaded, by checking WWW.isDone, and then you get your data via WWW.assetBundle.

This is just a very short explanation, it should be clearer to you by revising the demo I mentioned.