Calling all Unity game developers! Looking for a way to dramatically reduce your overall app size when creating 3D apps with Unity? Try this simple step โ moving your 3D models to the cloud!
Many players are hesitant to download large-sized apps & games. It takes more time, requires more bandwidth, and can really exhaust your phoneโs data plan (or can even prevent your app from being downloaded when a player is interested but is not connected to Wifi). By moving 3D assets to the cloud, thereby, reducing the overall size of your app, you are addressing all of your playersโ needs and more. Keeping your app size small and connecting it to the cloud means players will get the fastest download and freshest content.
echoAR, one of the newest members of the Unity Verified Solutions Partners program, is a cloud platform for AR/VR/3D applications that provides tools and network infrastructure to help developers connect their Unity app to the cloud and quickly deploy 3D content in AR. echoAR offers a 3D-first content management system (CMS) and delivery network (CDN) and a scalable BaaS infrastructure that enables Unity developers to build an AR/VR app backend in minutes and easily manage and publish 3D content. Hereโs a step-by-step guide to how move your 3D models to the cloud and reduce your Unity build size dramatically:
๐ Get an API key
- Register for FREE at echoAR and get your own API key (also check your inbox for an automatic email with your key).
- Upon registration you will be redirected to the console (you can also use the link in the registration email to get back to the console anytime.) Make sure your key is set in the header or type and load it yourself!
- You did it! ๐
๐จ Install the Unity SDK
You can easily use echoAR as a backend for your Unity project by following these steps:
- Download Unity SDK: Click the โDownloadsโ button in the top header bar to directly download the echoAR SDK for Unity.
- Open a Unity Project: Create a new or open an existing project in Unity (make sure your Unity version is up to date and has the required modules to build an app on your platform of choice!)
- Integrate Unity SDK: Double click on the echoAR-Unity.unitypackage file to import it into your Unity project. Alternativity, click Assets > Import Package > Custom Package... in the top menu bar and choose the echoAR-Unity.unitypackage file to import it into your Unity project.
- Thatโs it! ๐
๐งฐ Using the SDK
- Streaming 3D holograms into Unity: Either open the sample scene under Assets/echoAR/Examples/sample
- In the Inspector View for the echoAR game object or the empty game object that you created, update the API Key field with your API key.
- Add a 3D model through the console (hereโs how)
Go back to Unity and hit the Play button. The SDK will stream the 3D model into Unity.
Great work! ๐
๐ Transforming Content
Real-time updates and animations: You can go back to the console to add more 3D models, delete 3D models, add metadata, or change existing metadata associated with your entry and instantly see the changes in Unity even while the Unity project is running.
For example, you can add metadata with the key direction and the value right.
- This will make the 3D model rotated to the right.
- Build-in keywords: Many metadata keys are already pre-defined and allow you to control real-time transformations (such as x, y, z, direction, scale, shader, etc.). See here for the full list (built-in keywords will also be suggested through a drop-down list in the console but you can add any key and any value).
๐ฉโ๐ป Edit code
Now that you are able to successfully stream the 3D model into Unity, you can also make custom adjustments to it.
Each hologram will be instantiated with a script named CustomBehaviour.cs attached.
You can edit this script to create any behavior you would like while referencing additional data streamed from the cloud.
Learn how to add code to your Unity project while getting data from the cloud here.
Great work! ๐
๐คณ Adding AR capabilities
Now that you are successfully able to stream 3D content into Unity and know how to make custom adjustments, its time to add AR capabilities to your cloud-connected Unity project.
Unity provides a framework purpose-built for AR development called AR Foundation. It allows you to build across multiple mobile and wearable AR devices, such as Android with ARCore and iOS with ARKit.
Before using AR Foundation make sure that your iOS device is compatible with ARKit or that your Android device has ARCore or Google Play Services for AR installed.
1. Installing AR Foundation
- Clone the open-source Unity + AR Foundation + echoAR example project on GitHub and open it in Unity.
2. Setup a simple AR application
- Open the AR Foundation sample scene located in: Assets > AR Foundation > Scenes > SimpleAR > SimpleAR
- In the hierarchy click on the AR Session Origin game object.
- In the inspector view, look for the Place on Plane script and set the Placed Prefab to the echoAR prefab in the Assets > echoAR folder.
3. Set you API key
- Edit the echoAR prefab and set your API key through in the Inspector view.
Want to test the app in Unity before building? You can test the connection to echoAR by pressing Play to start the app on Unity.
Note that the Game view will show a black screen - that is expected as the Game view tries to access the mobile AR camera which doesn't exists when running on a desktop machine.
Switch to the Scene view and drag the echoAR prefab from Assets > echoAR into the hierarchy.
If the API key was set correctly you should be able to see 3D assets from the echoAR console stream into Unity.
Stopping Unity from playing should reset everything.
You are now ready to build the AR app on a mobile device.
4. Build and run the AR application
Connect your ARKit/ARCore-compatible mobile device or AR/VR headset to your desktop machine using a USB cable.
Go to File > Build Settings... or press Ctrl+Shift+B.
- Make sure to set your platform to (either Android, iOS, or Universal Windows Platform (UWP), etc.) by choosing the target platform and press the Switch Platform button on the bottom right corner.
- Verify that the SimpleAR scene is ticked in the Scenes in Build list and click Build And Run.
5. Use your AR application
First, add a 3D model to the console.
When the application is loaded on your mobile device you might be asked to approve camera access permission.
Move the phone around until a surface is detected.
Tap the screen to place the model on the surface.
The model will steam and render in front of you.
If the model is too big or too small, go back to the console and add metadata to affect its scale. After adding metadata the model should change automatically.
You did it! ๐
โ Troubleshooting
Troubleshoot issues here. You can check out our full documentation for other useful tutorials here and also reach out to our support team here.
echoAR (http://www.echoAR.xyz; Techstars โ19) is a cloud platform for augmented reality (AR) and virtual reality (VR) that provides tools and server-side infrastructure to help developers & companies quickly build and deploy AR/VR apps and experiences.
Top comments (0)