您好,登錄后才能下訂單哦!
這篇文章主要講解了“android studio集成unity導出工程怎么實現(xiàn)”,文中的講解內(nèi)容簡單清晰,易于學習與理解,下面請大家跟著小編的思路慢慢深入,一起來研究和學習“android studio集成unity導出工程怎么實現(xiàn)”吧!
1,android studio 2021.1.1.1
2, unity 2021.2.4
1,
2,
1,
2,導出結果 unityLibrary 就是我們想要的結果 launcher 暫時用不上
3, 在android 工程中
4,選擇unitylibarary 目錄
5,
6,更改 app gradle配置文件:
implementation project(path:':unityLibrary') implementation fileTree(dir: project(':unityLibrary').getProjectDir().toString()+('\\libs'), include: ['*.jar', '*.aar']) ndk { abiFilters 'armeabi-v7a', 'arm64-v8a' }
7,刪除manifest配置
8, 在 gradle.property 添加配置 不加這個會報錯
unityStreamingAssets=.unity3d, google-services-desktop.json, google-services.json, GoogleService-Info.plist
9,添加 value值 不加也會掛掉
<string name="game_view_content_description">Game view</string>
10,調(diào)用
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 調(diào)用 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調(diào)用Android public void UnityCallAndroid () { Toast.makeText(this,"unity調(diào)用android成功", Toast.LENGTH_LONG).show(); AndroidCallUnity(); } //android調(diào)用unity public void AndroidCallUnity () { //第1個參數(shù)為Unity場景中用于接收android消息的對象名稱 //第2個參數(shù)為對象上的腳本的一個成員方法名稱(腳本名稱不限制) //第3個參數(shù)為unity方法的參數(shù) UnityPlayer.UnitySendMessage("receiveObj", "UnityMethod", "This is args."); } }
c# 調(diào)用 java
private void OnBtnClickHandler() { using (jc = new AndroidJavaClass("com.unity3d.player.UnityPlayer")){ using (jo = jc.GetStatic<AndroidJavaObject>("currentActivity")){ jo.Call("UnityCallAndroid"); } } }
感謝各位的閱讀,以上就是“android studio集成unity導出工程怎么實現(xiàn)”的內(nèi)容了,經(jīng)過本文的學習后,相信大家對android studio集成unity導出工程怎么實現(xiàn)這一問題有了更深刻的體會,具體使用情況還需要大家實踐驗證。這里是億速云,小編將為大家推送更多相關知識點的文章,歡迎關注!
免責聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權內(nèi)容。