diff --git a/sdk-intergration/Assets/Editor.meta b/sdk-intergration/Assets/Editor.meta new file mode 100644 index 0000000..e19532c --- /dev/null +++ b/sdk-intergration/Assets/Editor.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: e309074d1095a643d9608f55ac6e3da5 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/sdk-intergration/Assets/Editor/BuildTool.cs b/sdk-intergration/Assets/Editor/BuildTool.cs new file mode 100644 index 0000000..fd99298 --- /dev/null +++ b/sdk-intergration/Assets/Editor/BuildTool.cs @@ -0,0 +1,82 @@ +using System.Linq; +using System; +using System.Collections.Generic; +using UnityEditor; + +public class BuildTool +{ + public enum EBundleType : byte + { + None, + FirstPack, + ALL + } + + public class BuildParams + { + public string outPath; + //public string version; + public string defineSymbol; + public string buildType; + //public int bundlesVersion; + public bool isPatch; + public bool aab = false; + public EBundleType bundleType = EBundleType.FirstPack; + public bool split = false; + } + + private const string Param_Out_Path = "--out"; + //private const string Param_Version = "--ver"; + //private const string Param_Bundle_Version_Code = "--code"; + private const string Param_Define_Symbol = "--define-symbol"; + private const string Param_Patch = "--patch"; + private const string Param_Split = "--split"; + private const string Param_Aab = "--aab"; + private const string Param_Bundle_Type = "--bundle-type"; + private const string Param_Build_Type = "--build-type"; + + public static void CIBuildIOS() + { + List args = new List(Environment.GetCommandLineArgs()); + + BuildParams bparams = new BuildParams() + { + outPath = args[args.IndexOf(Param_Out_Path) + 1], + //version = args[args.IndexOf(Param_Version) + 1], + defineSymbol = args.IndexOf(Param_Define_Symbol) == -1 ? string.Empty : args[args.IndexOf(Param_Define_Symbol) + 1], + buildType = args.IndexOf(Param_Build_Type) == -1 ? "New" : args[args.IndexOf(Param_Build_Type) + 1], + //bundlesVersion = int.Parse(args[args.IndexOf(Param_Bundle_Version_Code) + 1]), + isPatch = args.Contains(Param_Patch), + split = args.Contains(Param_Split), + aab = args.Contains(Param_Aab), + bundleType = Enum.Parse(args[args.IndexOf(Param_Bundle_Type) + 1]) + }; + + BuildAndroid(bparams); + } + + private static void BuildAndroid(BuildParams buildParams) + { + + var buildPlayerOptions = new BuildPlayerOptions + { + scenes = EditorBuildSettings.scenes.Select(x => x.path).ToArray(), + locationPathName = buildParams.outPath, + + target = BuildTarget.iOS, + options = BuildOptions.None, + }; + + var build_report = BuildPipeline.BuildPlayer(buildPlayerOptions); + + if (build_report?.summary.result == UnityEditor.Build.Reporting.BuildResult.Succeeded) + { + UnityEngine.Debug.Log($"[Build Player Success] {System.IO.Path.GetFullPath(buildParams.outPath)}"); + AssetDatabase.Refresh(ImportAssetOptions.ForceSynchronousImport); + } + else + { + UnityEngine.Debug.LogError($"Build Player Failed: {build_report?.summary}"); + } + } +} diff --git a/sdk-intergration/Assets/Editor/BuildTool.cs.meta b/sdk-intergration/Assets/Editor/BuildTool.cs.meta new file mode 100644 index 0000000..75fcea9 --- /dev/null +++ b/sdk-intergration/Assets/Editor/BuildTool.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: ff7ba79d8316f193a88a6b4cc4fdbe74 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: