Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to realize android studio Integration unity Export Project

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly explains "android studio integration unity export project how to achieve", the article explains the content is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "android studio integration unity export project how to achieve" it!

Environment

1,android studio 2021.1.1.1

2, unity 2021.2.4

New android project

one,

two,

Export unity Project

one,

2. The exported result unityLibrary is the result we want. Launcher is not available for the time being.

3, in the android project

4. Select the unitylibarary directory

five,

6. Change the app gradle configuration file:

Implementation project (path:':unityLibrary') implementation fileTree (dir: project (': unityLibrary'). GetProjectDir (). ToString () + ('\\ libs'), include: ['* .jar','* .aar']) ndk {abiFilters' armeabi-v7a', 'arm64-v8a'}

7, delete manifest configuration

8. Add configuration to gradle.property without this will cause an error

UnityStreamingAssets=.unity3d, google-services-desktop.json, google-services.json, GoogleService-Info.plist

9. If you add a value value, you will die if you don't add it.

Game view

10, call

Button myBtn= findViewById (R.id.button); myBtn.setOnClickListener (new View.OnClickListener () {@ Override public void onClick (View v) {Intent intent = new Intent (MainActivity.this,UnityPlayerActivity.class); startActivity (intent);}}); android c # call each other

Android calls c #

Package com.xingame.unitycallandroid;import android.os.Bundle;import android.widget.Toast;import com.unity3d.player.UnityPlayer;public class MainActivity extends UnityPlayerActivity {@ Override protected void onCreate (Bundle savedInstanceState) {super.onCreate (savedInstanceState); / / setContentView (R.layout.activity_main);} / / unity calls Android public void UnityCallAndroid () {Toast.makeText (this, "unity calls android successfully", Toast.LENGTH_LONG). Show () AndroidCallUnity () } / / android calls unity public void AndroidCallUnity () {/ / the first parameter is the object name used to receive android messages in the Unity scene / / the second parameter is a member method name of the script on the object (the script name is not limited) / / the third parameter is the parameter UnityPlayer.UnitySendMessage ("receiveObj", "UnityMethod", "This is args.") of the unity method. }}

C # call java

Private void OnBtnClickHandler () {using (jc = new AndroidJavaClass ("com.unity3d.player.UnityPlayer")) {using (jo = jc.GetStatic ("currentActivity")) {jo.Call ("UnityCallAndroid") } Thank you for your reading, the above is the content of "how to realize the android studio integrated unity export project". After the study of this article, I believe you have a deeper understanding of how to realize the android studio integrated unity export project, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report