In this short article, I will explain how to download and setup the AWS Mobile SDK for Unity, for use with a mobile app being created with Unity. It is quite easy to setup and Amazon has an easy to follow reference page.
For step by step directions, look here:
Of course, you have to have an AWS account to get started. The first thing you need to do is download the AWS mobile SDK for Unity. This can be obtained by clicking on this link:
Once the SDK is downloaded, extract it and open the folder. You should see something similar to this:
There are Unity Packages for all the AWS services you may want to use. You can import all the packages or just the ones you need. Here I am only going to use S3 and so will only import the S3 Package. This is done by double clicking on the package, which will open the import menu in Unity. Then click import from the menu. Note that you can also just drag the package into your assets folder in Unity as well:
Next we need to configure the AWS mobile SDK for Unity. First create a script. I will call this script AWSManager:
Next create an empty game object and attach the script to this object. I’m calling the game object AWS_Manager:
Now we need to properly configure the script. Don’t worry we only need to add two lines of code:
First we need to add the Amazon Namespace (using Amazon). Then we need to call the Unity Initializer in the awake method as seen above. This is the exact line of code you will also find in the AWS docs.
Now, back in the Unity editor, if you click the play button, you will see the script will add necessary components to our game object that will allow us to interact with AWS:
Lastly, we need to obtain an identity pool ID using Amazon Cognito. Login to AWS and open Cognito. Click on Manage Identity Pools:
On the next screen click Create New Identity Pool. This will take you to the screen below:
On the above screen name your identity pool. Here I am using the name of the app. Click on Enable Access to Unauthenticated Identities. Note that this is not required and could change based on your app. In this case, I am building an app that will not have a login service or require user login. For this reason I am allowing unauthenticated identities.
Click Create Pool and you will be taken to the below screen listing IAM Roles:
Make sure the IAM roles are configured properly for your specific case and then click Allow. This will create your Identity Pool and you will be ready to go.
These are the basic steps you need to follow when setting up AWS for Unity.