|
| 1 | +using System; |
| 2 | +using UnityEngine; |
| 3 | +using UnityEditor; |
| 4 | +using System.Collections.Generic; |
| 5 | + |
| 6 | +namespace Unity_Builder |
| 7 | +{ |
| 8 | + [CreateAssetMenu(fileName = "WindowBuildConfig", menuName = GlobalConst.CreateAssetMenu_Prefix + "/WindowBuildConfig")] |
| 9 | + public class WindowBuildConfig : BuildConfig |
| 10 | + { |
| 11 | + public override BuildTarget buildTarget => BuildTarget.StandaloneWindows64; |
| 12 | + |
| 13 | + /// <summary> |
| 14 | + /// CPP 빌드를 할지 체크, CPP빌드는 오래 걸리므로 Test빌드가 아닌 Alpha 빌드부터 하는걸 권장 |
| 15 | + /// </summary> |
| 16 | + public ScriptingImplementation scriptingBackEnd; |
| 17 | + |
| 18 | + public override void ResetSetting(BuildConfig buildConfig) |
| 19 | + { |
| 20 | + base.ResetSetting(buildConfig); |
| 21 | + |
| 22 | + BuildTargetGroup targetGroup = BuildPipeline.GetBuildTargetGroup(buildTarget); |
| 23 | + scriptingBackEnd = PlayerSettings.GetScriptingBackend(targetGroup); |
| 24 | + buildConfig.buildPath += |
| 25 | + "\n_{bundleVersion}.{bundleVersionCode}" + |
| 26 | + "\n_{scriptingBackEnd}"; |
| 27 | + } |
| 28 | + |
| 29 | + public override void OnPreBuild(IDictionary<string, string> commandLine, ref BuildPlayerOptions buildPlayerOptions) |
| 30 | + { |
| 31 | + base.OnPreBuild(commandLine, ref buildPlayerOptions); |
| 32 | + |
| 33 | + PlayerSettings.SetScriptingBackend(BuildTargetGroup.Standalone, scriptingBackEnd); |
| 34 | + } |
| 35 | + |
| 36 | + public override string GetBuildPath() |
| 37 | + { |
| 38 | + return base.GetBuildPath() |
| 39 | + .Replace("{scriptingBackEnd}", scriptingBackEnd.ToString()) |
| 40 | + + ".apk"; |
| 41 | + } |
| 42 | + } |
| 43 | + |
| 44 | + [CustomEditor(typeof(WindowBuildConfig))] |
| 45 | + public class WindowBuildConfig_Inspector : Editor |
| 46 | + { |
| 47 | + string _commandLine; |
| 48 | + |
| 49 | + public override void OnInspectorGUI() |
| 50 | + { |
| 51 | + base.OnInspectorGUI(); |
| 52 | + |
| 53 | + EditorGUILayout.Space(); |
| 54 | + EditorGUILayout.Space(); |
| 55 | + |
| 56 | + AndroidBuildConfig config = target as AndroidBuildConfig; |
| 57 | + if (GUILayout.Button("Reset to Current EditorSetting")) |
| 58 | + { |
| 59 | + config.ResetSetting(config); |
| 60 | + } |
| 61 | + |
| 62 | + if (GUILayout.Button("Build!")) |
| 63 | + { |
| 64 | + UnityBuilder.Build(config); |
| 65 | + } |
| 66 | + |
| 67 | + _commandLine = EditorGUILayout.TextField("commandLine", _commandLine); |
| 68 | + if (GUILayout.Button($"Build with \'{_commandLine}\'")) |
| 69 | + { |
| 70 | + string[] commands = _commandLine.Split(' '); |
| 71 | + for (int i = 0; i < commands.Length; i++) |
| 72 | + { |
| 73 | + string command = commands[i]; |
| 74 | + bool hasNextCommand = i + 1 < commands.Length; |
| 75 | + if (command.StartsWith("-")) |
| 76 | + { |
| 77 | + if (hasNextCommand) |
| 78 | + Environment.SetEnvironmentVariable(command, commands[i + 1]); |
| 79 | + else |
| 80 | + Environment.SetEnvironmentVariable(command, ""); |
| 81 | + } |
| 82 | + } |
| 83 | + |
| 84 | + UnityBuilder.Build(); |
| 85 | + } |
| 86 | + } |
| 87 | + } |
| 88 | +} |
0 commit comments