[Unity Dry Goods Tutorial] How to implement Unity and Android to call each other natively?

Unity is a cross-platform development tool, and publishing to mobile platforms is also an essential skill for most Unity developers. Due to the cross-platform nature of Unity, there will always be situations where the technical details of the mobile platform are not supported enough, or other native plug-ins need to be called. Here we talk about how to create an aar plug-in that can be called by Unity in Android Studio, so as to achieve the purpose of calling each other natively between Unity and Android.

development tools

Android Studio,Unity

Implementation steps

  1. Open AndroidStudio, create a new project, select NoActivity
  1. Select a storage path. Fill in the project name, the project name does not matter, it will not be used later; fill in the package name, the package name will need to be used later when citing.

  1. After creation, select the Android view, right-click on the app new—Module, create a new Module, and select Android Library. This is the library used to export later.
  1. Enter the newly created Library, right-click the folder in the figure below, and create a JavaClass. This java class is the class that will be referenced in Unity later.

  1. Next is a Demo scene: Call Android in Unity and pop up Tosat. And call back the specified method of Unity:

6. Export AAR: Select the newly created Library, select Build—Make Module, and package this library as aar

  1. Import into Unity: Put the AAR file just packaged into the Plugins--Android folder

  2. Unity call example:

summary

It is a very common development method for Unity and Android code to call each other. While making up for Unity's functions, it also provides more possibilities for the access of native SDKs. Newer versions of Unity already support direct import of java script files without packaging aar plugins.

3DCAT real-time cloud rendering provides new possibilities for mobile applications

With the gradual evolution of 3D interactive content, the size of the client is becoming larger and larger, and the hardware performance requirements for mobile devices are also getting higher and higher. hinder. The emergence of cloud rendering solves this pain point. Developers can store huge 3D resources in the cloud, and users can quickly experience the required 3D content at a minimal cost, clearing up many obstacles for enterprises and users. The application content running on the 3DCAT real-time rendering cloud can be flexibly embedded in any platform, supporting secure access by a large number of users, automatic load balancing and scaling and expansion.

If you have any needs, please feel free to contact us!

This article "[Unity Dry Goods Tutorial] How to implement Unity and Android to call each other natively? 》The content is organized and published by 3DCAT real-time cloud rendering solution provider . If you need to reprint, please indicate the source and link: [Unity Dry Tutorial] How to implement Unity and Android to call each other natively?

Guess you like

Origin blog.csdn.net/RealTime_3DCAT/article/details/128673889