Search Unity

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.

We also have step-by-step instructions on how to integrate Unity as a library on iOS and Android, including basic sample projects.

Please note that using Unity as a library requires that you deeply understand the architecture of Android/Java and iOS/Objective C applications.

Some limitations

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.

32 replies on “Add features powered by Unity to native mobile apps”

I tried unity as a plugin for android. When I am using the AR camera, it is giving me the error android_unity_bridge class error in android studio. Do you have any documentation for AR using unity as a plugin for android and ios(SWIFT)

> Unity as a Library supports full-screen rendering only; rendering on only a part of the screen is not supported.

Not supported as in “and will never be” or as in “but will be in the future”? :D

I can use this for AR in a lot of my applications so I’m excited! My only request is please release a tutorial or youtube video on an example of how to put this together as it might be a bit confusing doing guesswork once it releases.

Honestly, this was a lot more impressive until I saw “supports full-screen rendering only.” Really, every potential idea I had up until that point was cast aside.

Could I write a Apple Watch app with Unity with this change?

Like running the engine on the watch itself without a phone companion. Ideally I’d like my game to run both the watch and my phone so I can have a shared codebase.

Is it planed to be just for mobile?
It could be amazing to use Unity rendering capabilities as a runtime for native desktop apps.
I’m thinking in the direction of embedding Unity as a set of nodes for TouchDesigner for example.

Unity, just go ahead and build us something for Python. The ML interface is Python, the new UI scripting stuff supports python – just go ahead and give us python support @ the engine and be done with it :)

Aside from the terrible performance implications, why would you actually need this? C# really is not that hard to learn and write. You use the right tools for the right job. Python is used for machine learning because its an industry standard and performs well for AI. The same cant be said about python and the rest of use cases, so really putting it for the rest of the engine just takes us back to the point we were with javascript.

If you to write in python, why not just move to an actual python based graphics engine?

Because Unity has made a mission of making Unity a platform for more than just games. So while it is true that for regular games it would be a problematic issue – for other use cases (including as a teaching environment), Python would be excellent.

They used to have Boo script, ie it was “python” the same way that unityscript was “javascript”

Can’t wait for a python interface! it would be great for machine learning research projects!

Now, this would also be great on PC. We currently prototype the integration of Unity in a WPF application and had to setup a client/server structure to handle communication between the app and Unity…

@Stefan Maton @Unity

For some of our projects, we have implemented the same type of TCP communication protocol between a Unity application and a WPF / WinForm application. With the addition of the management of the inclusion of a Unity window in a WPF / WinForm Panel (SetParent, …). This works well but it would be comfortable to have native support for this type of integration.

It would certainly be great to have an easier integration of Unity into desktop apps too, e.g. Qt programs. Currently, we have a setup that uses some shared memory and communicates over a lot of callbacks. But this is super cumbersome.

This is in fact already possible for PC, and has been for some time now, though admittedly it isn’t well documented. We are planning to include documentation for how to embed Unity as a library for desktop platforms soon. Stay tuned.

Comments are closed.