static void BuildAndRun() { if (!PXR_ADBTool.GetInstance().CheckADBDevices()) { return; } apkOutputSuccessful = null; syncCancelToken = null; gradleBuildProcess = null; gradleTempExport = Path.Combine(Path.Combine(Application.dataPath, "../Temp"), "PXRGradleTempExport"); gradleExport = Path.Combine(Path.Combine(Application.dataPath, "../Temp"), "PXRGradleExport"); if (!Directory.Exists(gradleExport)) { Directory.CreateDirectory(gradleExport); } var buildResult = UnityBuildPlayer(); if (buildResult.summary.result == UnityEditor.Build.Reporting.BuildResult.Succeeded) { applicationIdentifier = PlayerSettings.GetApplicationIdentifier(BuildTargetGroup.Android); #if UNITY_2019_3_OR_NEWER productName = "launcher"; #else productName = Application.productName; #endif BuildRun(); } }
private static bool ProcessGradleProject() { try { var ps = System.Text.RegularExpressions.Regex.Escape("" + Path.DirectorySeparatorChar); var ignorePattern = string.Format("^([^{0}]+{0})?(\\.gradle|build){0}", ps); var syncer = new PXR_DirectorySyncer(gradleTempExport, gradleExport, ignorePattern); syncCancelToken = new PXR_DirectorySyncer.CancellationTokenSource(); var syncResult = syncer.Synchronize(syncCancelToken.Token); } catch (Exception e) { UnityEngine.Debug.Log("PXRLog Processing gradle project failed with exception: " + e.Message); return(false); } if (syncCancelToken.IsCancellationRequested) { return(false); } return(true); }
static void BuildAndRun() { GetWindow(typeof(PXR_BuildAndRunEW)); showCancel = false; buildFailed = false; totalBuildTime = 0; InitializeProgressBar(NUM_BUILD_AND_RUN_STEPS); IncrementProgressBar("Exporting Unity Project . . ."); if (!PXR_ADBTool.GetInstance().CheckADBDevices(log => {})) { buildFailed = true; return; } apkOutputSuccessful = null; syncCancelToken = null; gradleBuildProcess = null; UnityEngine.Debug.Log("PXRBuild: Starting Unity build ..."); SetupDirectories(); // 1. Get scenes to build in Unity, and export gradle project var buildResult = UnityBuildPlayer(); if (buildResult.summary.result == UnityEditor.Build.Reporting.BuildResult.Succeeded) { totalBuildTime += buildResult.summary.totalTime.TotalSeconds; // Set static variables so build thread has updated data showCancel = true; applicationIdentifier = PlayerSettings.GetApplicationIdentifier(BuildTargetGroup.Android); #if UNITY_2019_3_OR_NEWER productName = "launcher"; #else productName = Application.productName; #endif BuildRun(); return; } else if (buildResult.summary.result == UnityEditor.Build.Reporting.BuildResult.Cancelled) { UnityEngine.Debug.Log("Build canceled."); } else { UnityEngine.Debug.Log("Build failed."); } buildFailed = true; }
private static bool ProcessGradleProject() { DateTime syncStartTime = System.DateTime.Now; DateTime syncEndTime = System.DateTime.MinValue; try { var ps = System.Text.RegularExpressions.Regex.Escape("" + Path.DirectorySeparatorChar); // ignore files .gradle/** build/** foo/.gradle/** and bar/build/** var ignorePattern = string.Format("^([^{0}]+{0})?(\\.gradle|build){0}", ps); var syncer = new PXR_DirectorySyncer(gradleTempExport, gradleExport, ignorePattern); syncCancelToken = new PXR_DirectorySyncer.CancellationTokenSource(); var syncResult = syncer.Synchronize(syncCancelToken.Token); syncEndTime = System.DateTime.Now; } catch (Exception e) { UnityEngine.Debug.Log("PXRBuild: Processing gradle project failed with exception: " + e.Message); return(false); } if (syncCancelToken.IsCancellationRequested) { return(false); } // Record time it takes to sync gradle projects only if the sync was successful double syncTime = (syncEndTime - syncStartTime).TotalSeconds; if (syncTime > 0) { totalBuildTime += syncTime; } return(true); }