fix build
This commit is contained in:
@@ -16,38 +16,61 @@ public class BuildScript
|
||||
return scenes;
|
||||
}
|
||||
|
||||
[MenuItem("Build/Build Android APK")]
|
||||
[MenuItem("Build/Build Android APK (Direct)")]
|
||||
public static void BuildAndroid()
|
||||
{
|
||||
string outputPath = GetOutputPath();
|
||||
BuildAndroidTo(outputPath);
|
||||
BuildAndroidTo(outputPath, exportProject: false);
|
||||
}
|
||||
|
||||
[MenuItem("Build/Export Android Project")]
|
||||
public static void ExportAndroid()
|
||||
{
|
||||
string outputPath = Path.Combine(Directory.GetCurrentDirectory(), "Builds", "Android", "MosisVR");
|
||||
BuildAndroidTo(outputPath, exportProject: true);
|
||||
}
|
||||
|
||||
public static void BuildAndroidCI()
|
||||
{
|
||||
// Called from command line
|
||||
// Called from command line - check for export flag
|
||||
bool exportOnly = GetCommandLineArg("-export") == "true";
|
||||
string outputPath = GetCommandLineArg("-outputPath");
|
||||
|
||||
if (string.IsNullOrEmpty(outputPath))
|
||||
{
|
||||
outputPath = exportOnly
|
||||
? Path.Combine(Directory.GetCurrentDirectory(), "Builds", "Android", "MosisVR")
|
||||
: Path.Combine(Directory.GetCurrentDirectory(), "Builds", "Android", "MosisVR.apk");
|
||||
}
|
||||
|
||||
BuildAndroidTo(outputPath, exportOnly);
|
||||
}
|
||||
|
||||
public static void BuildAndroidDirectCI()
|
||||
{
|
||||
// Called from command line - direct APK build (no export)
|
||||
string outputPath = GetCommandLineArg("-outputPath");
|
||||
if (string.IsNullOrEmpty(outputPath))
|
||||
{
|
||||
outputPath = Path.Combine(Directory.GetCurrentDirectory(), "Builds", "Android", "MosisVR.apk");
|
||||
}
|
||||
|
||||
BuildAndroidTo(outputPath);
|
||||
BuildAndroidTo(outputPath, exportProject: false);
|
||||
}
|
||||
|
||||
private static void BuildAndroidTo(string outputPath)
|
||||
private static void BuildAndroidTo(string outputPath, bool exportProject = true)
|
||||
{
|
||||
// Ensure output directory exists
|
||||
string outputDir = Path.GetDirectoryName(outputPath);
|
||||
string outputDir = exportProject ? outputPath : Path.GetDirectoryName(outputPath);
|
||||
if (!Directory.Exists(outputDir))
|
||||
{
|
||||
Directory.CreateDirectory(outputDir);
|
||||
}
|
||||
|
||||
Debug.Log($"Building Android APK to: {outputPath}");
|
||||
Debug.Log($"Building Android {(exportProject ? "project" : "APK")} to: {outputPath}");
|
||||
|
||||
// Configure Android settings - export as Gradle project for manual build
|
||||
EditorUserBuildSettings.exportAsGoogleAndroidProject = true;
|
||||
// Configure Android settings
|
||||
EditorUserBuildSettings.exportAsGoogleAndroidProject = exportProject;
|
||||
EditorUserBuildSettings.buildAppBundle = false;
|
||||
PlayerSettings.SetScriptingBackend(BuildTargetGroup.Android, ScriptingImplementation.IL2CPP);
|
||||
PlayerSettings.Android.targetArchitectures = AndroidArchitecture.ARM64;
|
||||
|
||||
2
Assets/Plugins/Android/mainTemplate.gradle
generated
2
Assets/Plugins/Android/mainTemplate.gradle
generated
@@ -40,7 +40,7 @@ android {
|
||||
defaultConfig.externalNativeBuild{
|
||||
cmake {
|
||||
arguments += '-DUNITY_PROJECT_DIR="**DIR_UNITYPROJECT**"'
|
||||
arguments += '-DANDROID_SDK="' + getSdkDir() + '"'
|
||||
arguments += '-DANDROID_SDK="' + System.getenv("ANDROID_HOME") + '"'
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user