Journal 138 — Unity App Development, AR Demo Asset Bundle Option
Objective: To change the demo build and use an Asset Bundle
In the previous article, I got the app working in Windows. Now I want to change the app slightly by making the 3D model a Unity Asset Bundle to download from Amazon S3. This can be advantageous by making your app a smaller Play Store download, and then download a variety of 3D models or other larger assets of your choice from Amazon S3.
We can start by updating the AssetBundle tag of the 3D model.

We can create a script following Unity documentation, which will add a new menu option when selecting assets to create an Asset Bundle.
Please note the script is written to create a “StandaloneWindows” version of the Asset Bundle. We’ll eventually create another version that is suitable for an Android app.


Once this is done, you’ll see a new subfolder for the Asset Bundles.

Now in Amazon S3, we want to create a new bucket, and make it accessible for public downloads.


I also created a new IAM authorized and unauthorized role specifically for this demo and added premade Amazon policies that are for Read Only access.
After updating IAM, I went to Amazon Cognito and made a new Identity Pool for this app and added the authorized and unauthorized roles.

Back in Amazon S3, I uploaded the asset bundle from the Unity Assets.

In the file settings, you will need to edit the Access Control List (ACL) and make sure the file is set for read only access for the public.

In Unity, we need to set up a new AWSManager game object and C# script to handle the viewing and getting file, and download. To start, we need to add the AWS assemblies that we previously set up when working with a Service Adjustment app that uploaded and downloaded user data files from Amazon S3.

In the AWS Manager script, we can first make it into a singleton pattern.

Then we can set up the S3Client and S3Region properties.

We want to first make a function to confirm we can at least connect to Amazon S3 and get the file in question.


Now that this works, we can make a new function to download the asset bundle.

Now we can check this in action.

So, we end up with a successful download. The 3D model is a child of the ImageTarget. However, the size and rotation are not correct, and the Animator component reference is lost, so the UI buttons don’t work.
After the horse is instantiated, I will run a function to get the animation component reconnected in the UIManager.


Next, I will fix the scale and rotation.

Lastly, I need to fix the callout label so that the LineRenderer component shows correctly. I can fix this by finding the horse game object and finding the target which is a child of the horse.

Let’s see the results.

Note I found a couple more issues when building in Android. Essentially the Mesh Renderer, Materials, and Animator were not showing correctly. I found this issue resolved based on this discussion about one of the default Project Settings to uncheck.

Thank you for your time!