Unity

Learn how to configure Unity for use with Filebase.

What is Unity?

Unity is a popular game design and development engine that can be used to create a variety of 2D and 3D games. The AWS SDK for .NET can be used for Unity to interact with Filebase.

Read below to learn how to use Unity with Filebase.

Prerequisites:

Special thanks to Eric Vander Wal from Nervos Network for putting together the GitHub repo of scripts for this SDK creating a video tutorial showcasing this tutorial, which can be viewed here.

1. Open the Unity Hub application.

Sign in with your Unity account, then select ‘Projects’. Select ‘New Project’ to create a new project, or select an existing project you’d like to use.

2. Select a project template, then create a new project.

3. Next, download the following Unity SDK package that has been modified for use with Filebase:

git clone https://github.com/ericvanderwal/UnityFilebaseSDK.git

4. Next, open the Unity Filebase SDK directory.

Navigate to the Assets directory, then click and drag the FilebaseSDK folder into the Unity project’s Assets folder.

5. Open the FilebaseSDK folder, then navigate to the Filebase subdirectory.

Inside, you will find a Script and a Sample folder. Scripts contains the necessary functionality scripts that are used to interact with Filebase, and Samples contains sample Unity projects and scripts that can be used.

6. Before using any sample projects, open the Scripts directory then open the Paths file.

7. In the Paths file, replace the following variables to reflect your Filebase Access Key and Secret Key:

public const string AccessKey = "FILEBASE_ACCESS_KEY";

public const string SecretKey = "FILEBASE_SECRET_KEY";

8. Next, select the ‘Filebase Example’ from the project’s Hierarchy, then select ‘Add Component’ on the right sidebar menu.

9. Select ‘Scripts’, then select the ‘Get All Objects’ script. This script will return all objects in the specified bucket.

10. Enter your Filebase bucket name.

Then select the ‘Console’ tab to view the console output, and select the ‘Play’ button from the top center of the screen to run your script.

11. All object names in the specified bucket will be returned to the console.

12. Next, add another new component, select ‘Scripts’ again, then select the ‘DownloadObjects’ script.

Enter your Filebase bucket name and the object name you want to download.

13. Select the ‘Console’ tab to view the console output, and select the ‘Play’ button from the top center of the screen to run your script.

14. The console output will include where the file has been downloaded to.

15. Next, add another new component, select ‘Scripts’ again, then select the ‘UploadObjects’ script.

Enter your Filebase bucket name and a project file to upload. This example uses the file located at Assets/Scenes/SampleScene.unity.

16. Select the ‘Console’ tab to view the console output, and select the ‘Play’ button from the top center of the screen to run your script.

17. The console will return confirmation that the file has been uploaded.

18. Right click in the Hierarchy window, select ‘UI > Button - TextMeshPro’

19. When prompted, select the ‘Import TMP Essentials’ button.

20. Then select the ‘Filebase Example’ component, then add another new component, selecting ‘Scripts’, then selecting the ‘Camera Capture’ script.

21. Enter your Filebase bucket name, then select your newly created button and its associated input field.

22. Select the run button from the center of the window, then click on your button in the scene window.

This button takes a screenshot of your current workspace and creates an image file of it.

Each of these scripts can be repurposed to upload and download different game assets to Filebase.

Last updated