Skip to content

Commit be88e2b

Browse files
committed
Add builder script, update project settings
1 parent 9f95e7c commit be88e2b

File tree

6 files changed

+183
-1
lines changed

6 files changed

+183
-1
lines changed

Assets/Scripts/Infrastructure.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/Scripts/Infrastructure/Editor.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
using System.Collections.Generic;
2+
using System.IO;
3+
using UnityEditor;
4+
using UnityEditor.Build.Reporting;
5+
using UnityEngine;
6+
7+
namespace Infrastructure.EditorHelpers
8+
{
9+
public class Builder
10+
{
11+
[MenuItem("Tools/AutoBuilder/Android")]
12+
public static void BuildDevForAndroid()
13+
{
14+
List<string> scenes = new List<string>();
15+
foreach (var s in EditorBuildSettings.scenes)
16+
{
17+
scenes.Add(s.path);
18+
}
19+
string buildPath = "Builds/Android/Development";
20+
if (!Directory.Exists(buildPath))
21+
Directory.CreateDirectory(buildPath);
22+
23+
Debug.Log("--Builder: BuildDevForAndroid: StartBuild");
24+
string buildName = GetBuildName();
25+
Debug.Log($"--Builder: BuildDevForAndroid: buildName {buildName}");
26+
var result = BuildPipeline.BuildPlayer(scenes.ToArray(), $"{buildPath}/{buildName}", BuildTarget.Android, BuildOptions.Development);
27+
Debug.Log($"--Builder: BuildDevForAndroid: build finished path = {result.summary.outputPath}");
28+
29+
// HACK: Small Hack so we don't exit the editor on local machines
30+
if (string.IsNullOrWhiteSpace(GetArg("buildName")))
31+
return;
32+
if (result.summary.result == BuildResult.Succeeded)
33+
EditorApplication.Exit(0);
34+
else
35+
EditorApplication.Exit(1);
36+
}
37+
38+
private static string GetBuildName()
39+
{
40+
string name = GetArg("buildName");
41+
return !string.IsNullOrWhiteSpace(name) ? name : $"v{PlayerSettings.bundleVersion}_b{PlayerSettings.Android.bundleVersionCode}.apk";
42+
}
43+
44+
// source: https://stackoverflow.com/questions/39843039/game-development-how-could-i-pass-command-line-arguments-to-a-unity-standalo#answer-45578115
45+
private static string GetArg(string name)
46+
{
47+
var args = System.Environment.GetCommandLineArgs();
48+
for (int i = 0; i < args.Length; i++)
49+
{
50+
if (args[i] == name && args.Length > i + 1)
51+
{
52+
return args[i + 1];
53+
}
54+
}
55+
return null;
56+
}
57+
}
58+
}
59+

Assets/Scripts/Infrastructure/Editor/Builder.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ProjectSettings/GraphicsSettings.asset

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ GraphicsSettings:
3636
- {fileID: 10753, guid: 0000000000000000f000000000000000, type: 0}
3737
- {fileID: 10770, guid: 0000000000000000f000000000000000, type: 0}
3838
- {fileID: 10783, guid: 0000000000000000f000000000000000, type: 0}
39+
- {fileID: 16000, guid: 0000000000000000f000000000000000, type: 0}
40+
- {fileID: 16001, guid: 0000000000000000f000000000000000, type: 0}
41+
- {fileID: 16003, guid: 0000000000000000f000000000000000, type: 0}
42+
- {fileID: 17000, guid: 0000000000000000f000000000000000, type: 0}
3943
m_PreloadedShaders: []
4044
m_SpritesDefaultMaterial: {fileID: 10754, guid: 0000000000000000f000000000000000,
4145
type: 0}

ProjectSettings/ProjectSettings.asset

Lines changed: 93 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,99 @@ PlayerSettings:
270270
androidGamepadSupportLevel: 0
271271
resolutionDialogBanner: {fileID: 0}
272272
m_BuildTargetIcons: []
273-
m_BuildTargetPlatformIcons: []
273+
m_BuildTargetPlatformIcons:
274+
- m_BuildTarget: Android
275+
m_Icons:
276+
- m_Textures: []
277+
m_Width: 432
278+
m_Height: 432
279+
m_Kind: 2
280+
m_SubKind:
281+
- m_Textures: []
282+
m_Width: 324
283+
m_Height: 324
284+
m_Kind: 2
285+
m_SubKind:
286+
- m_Textures: []
287+
m_Width: 216
288+
m_Height: 216
289+
m_Kind: 2
290+
m_SubKind:
291+
- m_Textures: []
292+
m_Width: 162
293+
m_Height: 162
294+
m_Kind: 2
295+
m_SubKind:
296+
- m_Textures: []
297+
m_Width: 108
298+
m_Height: 108
299+
m_Kind: 2
300+
m_SubKind:
301+
- m_Textures: []
302+
m_Width: 81
303+
m_Height: 81
304+
m_Kind: 2
305+
m_SubKind:
306+
- m_Textures: []
307+
m_Width: 192
308+
m_Height: 192
309+
m_Kind: 0
310+
m_SubKind:
311+
- m_Textures: []
312+
m_Width: 144
313+
m_Height: 144
314+
m_Kind: 0
315+
m_SubKind:
316+
- m_Textures: []
317+
m_Width: 96
318+
m_Height: 96
319+
m_Kind: 0
320+
m_SubKind:
321+
- m_Textures: []
322+
m_Width: 72
323+
m_Height: 72
324+
m_Kind: 0
325+
m_SubKind:
326+
- m_Textures: []
327+
m_Width: 48
328+
m_Height: 48
329+
m_Kind: 0
330+
m_SubKind:
331+
- m_Textures: []
332+
m_Width: 36
333+
m_Height: 36
334+
m_Kind: 0
335+
m_SubKind:
336+
- m_Textures: []
337+
m_Width: 192
338+
m_Height: 192
339+
m_Kind: 1
340+
m_SubKind:
341+
- m_Textures: []
342+
m_Width: 144
343+
m_Height: 144
344+
m_Kind: 1
345+
m_SubKind:
346+
- m_Textures: []
347+
m_Width: 96
348+
m_Height: 96
349+
m_Kind: 1
350+
m_SubKind:
351+
- m_Textures: []
352+
m_Width: 72
353+
m_Height: 72
354+
m_Kind: 1
355+
m_SubKind:
356+
- m_Textures: []
357+
m_Width: 48
358+
m_Height: 48
359+
m_Kind: 1
360+
m_SubKind:
361+
- m_Textures: []
362+
m_Width: 36
363+
m_Height: 36
364+
m_Kind: 1
365+
m_SubKind:
274366
m_BuildTargetBatching: []
275367
m_BuildTargetGraphicsAPIs: []
276368
m_BuildTargetVRSettings: []

0 commit comments

Comments
 (0)