The latest Unity beta build 2019.3.a2 brings the ability to integrate its runtime components into native apps developed with Android Studio. This opens up a host of possibilities for developers. Here’s why it matters to you, and what you need to know to get started.
Why you should care
Unity is an extremely powerful and flexible tool for game developers that makes it easy to build apps and games on Android and across platforms. It is, in fact, the most popular game engine on the Google Play Store, and has been used to create many of its best-known and most-loved titles.
Also read: Unity certification for developers: Is it worth it?
As a game engine, Unity makes it extremely easy to render 3D graphics to the screen, implement realistic physics and lighting, or integrate AR and VR content. Doing the same is infinitely more arduous and complex when using Android Studio alone.
But while this is true, Unity is also limited in some capacities. While it’s possible to make non-game applications with a bit of out-the-box thinking, this is definitely not its intended purpose and it shows.
Unity makes it extremely easy to render 3D graphics to the screen, implement realistic physics and lighting, or integrate AR and VR content.
If you want your app to use web views, text boxes, or other features, then you’re better off using Android Studio. This is particularly true if your goal is to conform to the Material Design guidelines. Likewise, many native features are completely inaccessible through Unity alone.
Also read: Unity 2019.1 brings exciting new features for Android developers
It’s a case of “horses for courses” then, but what if you want the best of both worlds? By using Unity as a library, you’ll be able to use a regular Android app layout with all the features of a regular Android Studio project, but with integrated 3D graphics, AR elements and more.
Developers might use this to build regular apps with 3D animated backgrounds and elements. Unity suggests that brands might likewise use this feature to integrate AR marketing features. Let us know in the comments how you see this being used!
The other good news is that it should theoretically be possible for developers to take their existing apps and simply add the 3D content.
How Unity as a library works
To use this feature, you’ll need to create your Unity content as a regular Unity project. You’ll also need an Android Studio project that you want to integrate this into, and you’ll need the latest versions of both Android Studio (3.3.2 at the time of writing) and the latest Unity beta (2019.3.a2).
You will use the Unity editor to build an APK and will place this in a folder called androidBuild. Both this and your native project should be contained in the same folder.
You’ll then add the Unity Library module to your native app by making a few edits, and you’ll need to display the Unity content via your native project’s code.
You can find detailed instructions, along with a sample project here. It’s a relatively straightforward process and with a little reverse engineering, you should be able to follow the same steps in your own projects.
Undoubtedly, this is going to be a useful option for some developers. And it’s great to see a feature like this from Unity.
There are some limitations imposed on the feature though. Unity only supports full-screen rendering for example, meaning the notification tray won’t be visible at runtime and you can’t load games into views within a larger app. Likewise, you won’t be able to use more than one instance of the Unity runtime at once. Certain third-party plugins may need some also adapting.
Unity is also keen to point out that as it is no longer controlling the lifecycle of its runtime, it can’t guarantee perfect operation at all times.
There are some limitations imposed on the feature though.
While the basic process seems easy-enough to follow, several users have already reported bugs and issues that they’ve run into. We should keep in mind that this feature is still in beta. But with Google updating the Android platform at a rate of knots, I wouldn’t be surprised to find compatibility issues popping up down the line. This has been a problem with some other partners, such as Oculus.
We’ll have to wait and see. But even if this isn’t always the smoothest process, the ability to use Unity as a library in Android Studio is certainly a very welcome addition and one that I’m sure many developers will embrace with open arms. What do you think?
Also Publish AT: https://www.androidauthority.com/unity-as-a-library-1027008/