第一步,确保jdk,sdk,gradle版本一致
unity 3d的配置
idea配置
第二步,整个unity导出安卓项目到idea
idea配置项目(修改gradl配置)
gradle配置代码
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
插件代码:
plugins {// If you are changing the Android Gradle Plugin version, make sure it is compatible with the Gradle version preinstalled with Unity// See which Gradle version is preinstalled with Unity here https://docs.unity3d.com/Manual/android-gradle-overview.html// See official Gradle and Android Gradle Plugin compatibility table here https://developer.android.com/studio/releases/gradle-plugin#updating-gradle// To specify a custom Gradle version in Unity, go do "Preferences > External Tools", uncheck "Gradle Installed with Unity (recommended)" and specify a path to a custom Gradle versionid 'com.android.application' version '8.6.0-alpha07' apply falseid 'com.android.library' version '8.6.0-alpha07' apply false
}
第三步,unityLibrary导入到已有安卓项目
报错:
Caused by: org.gradle.api.resources.MissingResourceException: Could not read script 'D:\IDEA-items\quanji_xitong\shared\keepUnitySymbols.gradle' as it does not exist.
解决方法:
路径代码(需要变为自己的路径):
apply from: 'D:/Unity_3D/Quanji_export-test/shared/keepUnitySymbols.gradle'
导入依赖包:
选择unityLibrary模块:
添加依赖:
implementation(project(":unityLibrary"))
删除Gradle Projects方法
unity结束时摧毁主进程解决方案,添加主进程和unity进程:
主进程中:
android:process=":MainActivity"
unity中:
android:process=":UnityActivity"