Unity 2019.3 will add support for using Unity as a library controlled by native Android/Java and iOS/Objective C apps so you can easily insert AR and other Unity features.
We know there are times when developers using native platform technologies (like Android/Java and iOS/Objective C) want to include features powered by Unity in their apps and games. Starting with Unity 2019.3.a2, you can integrate the Unity runtime components and your content into a native platform project so you can use Unity as a library.
This means that you can now insert features powered by Unity, such as augmented reality (AR), 3D/2D real-time rendering, 2D mini-games, and more, directly into your native mobile apps.
How it works: Changes to project structure
The Unity runtime library exposes controls to manage when and how to load/activate/unload within the native application.
The mobile app build process overall is still the same. Unity creates the iOS Xcode and Android Gradle projects.
However, to enable this feature, we changed the structure of the generated iOS Xcode and Android Gradle projects as follows:
- A library part – iOS framework and Android Archive (AAR) file – that includes all source files and plugins
- A thin launcher part that includes app representation data and runs the library part
You can find out more details about the changes to the Xcode/Android Gradle projects in this forum post.
Please note that using Unity as a library requires that you deeply understand the architecture of Android/Java and iOS/Objective C applications.
We tested many scenarios for Unity as a library hosted by a native app. But since Unity no longer controls the lifecycle of the runtime, we cannot guarantee it will work in all possible use cases. For example:
- Unity as a Library supports full-screen rendering only; rendering on only a part of the screen is not supported.
- Loading more than one instance of the Unity runtime is not supported.
- You may need to adapt third-party plugins (native or managed) for them to work properly.
Powering the technology that is revolutionizing marketing campaigns
Unity as a library is a tremendous advantage for various use cases across industries. In particular, brands and creative agencies can now easily insert AR directly into their native mobile apps.
Cutting-edge brands see the value in adding AR to their traditional marketing campaigns. With Unity support for Unity as a library, the process is streamlined. Brands and creative agencies no longer have to rebuild their app to insert AR or hack together a solution to use Unity as a library.
Consumers are ready for AR marketing. AR lets brands foster a personal relationship with consumers, and we’re excited to offer a solution that powers the evolution of marketing.
To learn more about how brands and creative agencies are using Unity, check out our solutions page.