From 5f7a9154384ae9307f55e14e73cea6d216b3f784 Mon Sep 17 00:00:00 2001 From: "a.gorbunov" <0alexgorbynov0@gmail.com> Date: Wed, 25 Oct 2023 15:02:47 +0300 Subject: [PATCH 1/2] Add ci. --- Assets/00_CI.meta | 8 +++++ Assets/00_CI/BuilderTool.cs | 72 +++++++++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+) create mode 100644 Assets/00_CI.meta create mode 100644 Assets/00_CI/BuilderTool.cs diff --git a/Assets/00_CI.meta b/Assets/00_CI.meta new file mode 100644 index 00000000..4972ca8c --- /dev/null +++ b/Assets/00_CI.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 4feeb981ea509cd42967c3637667453d +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/00_CI/BuilderTool.cs b/Assets/00_CI/BuilderTool.cs new file mode 100644 index 00000000..156cb262 --- /dev/null +++ b/Assets/00_CI/BuilderTool.cs @@ -0,0 +1,72 @@ +#if UNITY_EDITOR + +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using UnityEditor; +using UnityEditor.Build; +using UnityEditor.Build.Reporting; +using UnityEditor.SceneManagement; +using UnityEngine; + +public static class BuilderTool +{ + public static NamedBuildTarget GetBuildTarget() => NamedBuildTarget.Standalone; + + [MenuItem("Builds/Build")] + public static void Build() + { + var productName = $"VR Project 3"; + var rootPath = Application.dataPath + "/../"; + var bundleNumber = PlayerSettings.Android.bundleVersionCode; + bundleNumber++; + var buildRootPath = Path.Combine(rootPath, "Builds2"); + var buildName = $"{productName}.exe"; + var buildPlayerOptions = new BuildPlayerOptions(); + + var defines = GetActualDefines(); + ApplyDefines(defines); + + + PlayerSettings.applicationIdentifier = $"com.BoggArt.OscSender.{productName}"; + PlayerSettings.productName = productName; + buildPlayerOptions.scenes = GetScenes(); + buildPlayerOptions.locationPathName = Path.Combine(buildRootPath, buildName); + buildPlayerOptions.target = BuildTarget.StandaloneWindows64; + buildPlayerOptions.options = BuildOptions.None; + buildPlayerOptions.extraScriptingDefines = defines; + + if (!Directory.Exists(buildRootPath)) + Directory.CreateDirectory(buildRootPath); + + BuildReport report = BuildPipeline.BuildPlayer(buildPlayerOptions); + BuildSummary summary = report.summary; + + if (summary.result == BuildResult.Succeeded) + { + Debug.Log("Build succeeded: " + summary.totalSize + " bytes"); + } + + if (summary.result == BuildResult.Failed) + { + Debug.Log("Build failed"); + } + } + + public static string[] GetActualDefines() + { + return PlayerSettings.GetScriptingDefineSymbols(GetBuildTarget()).Split(";").ToArray(); + } + + public static string[] GetScenes() + { + return EditorBuildSettings.scenes.Select(s => s.path).ToArray(); + } + + private static void ApplyDefines(string[] defines) + { + PlayerSettings.SetScriptingDefineSymbols(GetBuildTarget(), defines); + } +} +#endif \ No newline at end of file From 1317e2a107dfe4aca7d453e3ccb7e30d6f7e084f Mon Sep 17 00:00:00 2001 From: "a.gorbunov" <0alexgorbynov0@gmail.com> Date: Wed, 25 Oct 2023 15:09:40 +0300 Subject: [PATCH 2/2] fix ci. --- Assets/00_CI/BuilderTool.cs | 2 +- Assets/00_CI/BuilderTool.cs.meta | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 Assets/00_CI/BuilderTool.cs.meta diff --git a/Assets/00_CI/BuilderTool.cs b/Assets/00_CI/BuilderTool.cs index 156cb262..f0c82357 100644 --- a/Assets/00_CI/BuilderTool.cs +++ b/Assets/00_CI/BuilderTool.cs @@ -21,7 +21,7 @@ public static class BuilderTool var rootPath = Application.dataPath + "/../"; var bundleNumber = PlayerSettings.Android.bundleVersionCode; bundleNumber++; - var buildRootPath = Path.Combine(rootPath, "Builds2"); + var buildRootPath = Path.Combine(rootPath, "Builds"); var buildName = $"{productName}.exe"; var buildPlayerOptions = new BuildPlayerOptions(); diff --git a/Assets/00_CI/BuilderTool.cs.meta b/Assets/00_CI/BuilderTool.cs.meta new file mode 100644 index 00000000..f4d57767 --- /dev/null +++ b/Assets/00_CI/BuilderTool.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: ae6a85ec006b4154d8d3734b2378dd80 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: