com.amanotes.gdk 0.2.49 → 0.2.50
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/Editor/AmaGDKEditor.cs +26 -8
- package/Editor/Extra/GDKAutoBuild.cs +891 -0
- package/Editor/Extra/GDKAutoBuild.cs.meta +3 -0
- package/Editor/Extra/GDKProjectCP.cs +158 -0
- package/Editor/Extra/GDKProjectCP.cs.meta +11 -0
- package/Editor/Extra.meta +8 -0
- package/Extra/AmaGDKInstaller.unitypackage +0 -0
- package/Extra/AndroidPostProcessor.unitypackage +0 -0
- package/Extra/{AmaGDKProject.unitypackage.meta → AndroidPostProcessor.unitypackage.meta} +1 -1
- package/Extra/CheckDiskSpace.unitypackage +0 -0
- package/Extra/CheckDiskSpace.unitypackage.meta +7 -0
- package/Extra/SDKVersionTracking.unitypackage +0 -0
- package/Packages/AmaGDKConfig.unitypackage +0 -0
- package/Packages/AmaGDKExample.unitypackage +0 -0
- package/Packages/AmaGDKTest.unitypackage +0 -0
- package/Packages/AppsFlyerAdapter.unitypackage +0 -0
- package/Packages/FirebaseAnalyticsAdapter.unitypackage +0 -0
- package/Packages/FirebaseRemoteConfigAdapter.unitypackage +0 -0
- package/Packages/IronSourceAdapter.unitypackage +0 -0
- package/Packages/RevenueCatAdapter.unitypackage +0 -0
- package/Runtime/AmaGDK.Ads.cs +3 -2
- package/Runtime/AmaGDK.cs +1 -1
- package/Runtime/Internal/AmaGDK.Internal.cs +1 -0
- package/package.json +1 -1
- package/Extra/AmaGDKProject.unitypackage +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.2.50 - 2024-02-20]
|
|
4
|
+
- New feature: Modify Android post processor
|
|
5
|
+
- [Fix] remove installer should be skipped in DEV mode
|
|
6
|
+
- New feature: Check Disk Space
|
|
7
|
+
- Update version tracking: Add SkAdnetwork count
|
|
8
|
+
- Add check internet option for Ad module
|
|
9
|
+
|
|
3
10
|
## [0.2.49 - 2024-01-29]
|
|
4
11
|
- New feature: SDK version tracking
|
|
5
12
|
- New feature: Google Consent Management (CMP)
|
package/Editor/AmaGDKEditor.cs
CHANGED
|
@@ -31,11 +31,14 @@ namespace Amanotes.Editor
|
|
|
31
31
|
private static bool showConfigDetail;
|
|
32
32
|
private static bool showAdapterInstaller;
|
|
33
33
|
private static bool showExampleDetail;
|
|
34
|
-
private static bool
|
|
34
|
+
private static bool showExtra;
|
|
35
35
|
|
|
36
36
|
// DO NOT PUT [NonSerialized]
|
|
37
37
|
private static bool adapterScanned = false;
|
|
38
38
|
private static bool searchedForConfig = false;
|
|
39
|
+
|
|
40
|
+
private static bool extraScanned = false;
|
|
41
|
+
private static readonly List<string> extraPackages = new List<string>();
|
|
39
42
|
|
|
40
43
|
private static readonly List<string> adapterPackages = new List<string>();
|
|
41
44
|
|
|
@@ -145,17 +148,18 @@ namespace Amanotes.Editor
|
|
|
145
148
|
adapterPackages.Add(Path.GetFileName(adapterPath[i]));
|
|
146
149
|
}
|
|
147
150
|
}
|
|
148
|
-
|
|
149
|
-
private void
|
|
151
|
+
|
|
152
|
+
private void ScanForExtraPackages()
|
|
150
153
|
{
|
|
151
|
-
|
|
154
|
+
extraScanned = true;
|
|
155
|
+
extraPackages.Clear();
|
|
156
|
+
string[] extraPath = Directory.GetFiles(Res.EXTRA_PATH, "*.unitypackage", SearchOption.AllDirectories);
|
|
157
|
+
for (var i = 0; i < extraPath.Length; i++)
|
|
152
158
|
{
|
|
153
|
-
|
|
154
|
-
AssetDatabase.ImportPackage(package, true);
|
|
159
|
+
extraPackages.Add(Path.GetFileName(extraPath[i]));
|
|
155
160
|
}
|
|
156
161
|
}
|
|
157
162
|
|
|
158
|
-
|
|
159
163
|
private void DrawGUI_AdapterList()
|
|
160
164
|
{
|
|
161
165
|
if (!adapterScanned) ScanForAdapterPackages();
|
|
@@ -168,6 +172,19 @@ namespace Amanotes.Editor
|
|
|
168
172
|
}
|
|
169
173
|
}
|
|
170
174
|
}
|
|
175
|
+
|
|
176
|
+
private void DrawGUI_ExtraList()
|
|
177
|
+
{
|
|
178
|
+
if (!extraScanned) ScanForExtraPackages();
|
|
179
|
+
foreach (string extra in extraPackages)
|
|
180
|
+
{
|
|
181
|
+
if (GUILayout.Button(ObjectNames.NicifyVariableName(extra)))
|
|
182
|
+
{
|
|
183
|
+
var package = $"{Res.PACKAGE_PATH}{extra}";
|
|
184
|
+
AssetDatabase.ImportPackage(package, false);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
171
188
|
|
|
172
189
|
private void DrawGUI_ExampleScene()
|
|
173
190
|
{
|
|
@@ -272,6 +289,7 @@ namespace Amanotes.Editor
|
|
|
272
289
|
|
|
273
290
|
if (!searchedForConfig) TryLoadConfigAsset();
|
|
274
291
|
if (!adapterScanned) ScanForAdapterPackages();
|
|
292
|
+
if (!extraScanned) ScanForAdapterPackages();
|
|
275
293
|
|
|
276
294
|
if (configAsset == null)
|
|
277
295
|
{
|
|
@@ -295,7 +313,7 @@ namespace Amanotes.Editor
|
|
|
295
313
|
EditorGUILayout.Space();
|
|
296
314
|
AmaGUI.Foldout("Config", ref showConfigDetail, DrawGUI_ConfigDetail, DrawGUI_ConfigAsset);
|
|
297
315
|
AmaGUI.Foldout("Adapters", ref showAdapterInstaller, DrawGUI_AdapterList);
|
|
298
|
-
AmaGUI.Foldout("
|
|
316
|
+
AmaGUI.Foldout("Extras", ref showExtra, DrawGUI_ExtraList);
|
|
299
317
|
Profiler.EndSample();
|
|
300
318
|
}
|
|
301
319
|
|
|
@@ -0,0 +1,891 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using System.Collections.Generic;
|
|
3
|
+
using System.Diagnostics;
|
|
4
|
+
using System.IO;
|
|
5
|
+
using System.Linq;
|
|
6
|
+
using UnityEditor;
|
|
7
|
+
using UnityEngine;
|
|
8
|
+
using UnityEngine.Events;
|
|
9
|
+
using Debug = UnityEngine.Debug;
|
|
10
|
+
using UnityObject = UnityEngine.Object;
|
|
11
|
+
|
|
12
|
+
namespace Amanotes.Editor
|
|
13
|
+
{
|
|
14
|
+
[CreateAssetMenu(menuName = "AmaGDK/Build Config")]
|
|
15
|
+
public class GDKAutoBuild : ScriptableObject
|
|
16
|
+
{
|
|
17
|
+
private const string DEFAULT_BUILD_FOLDER = "../../_Build";
|
|
18
|
+
|
|
19
|
+
public KeystoreInfo keystore;
|
|
20
|
+
public string buildFolder = DEFAULT_BUILD_FOLDER;
|
|
21
|
+
public Texture2D icon;
|
|
22
|
+
|
|
23
|
+
public List<BuildInfo> listBuild = new List<BuildInfo>();
|
|
24
|
+
|
|
25
|
+
public List<UnityObject> listUnused;
|
|
26
|
+
public BuildRequestTS buildRQ;
|
|
27
|
+
public UnityEvent beforeBuild;
|
|
28
|
+
public TextAsset shTemplate;
|
|
29
|
+
|
|
30
|
+
[NonSerialized] private BuildInfo _buildInfo;
|
|
31
|
+
[NonSerialized] private int _lockCount;
|
|
32
|
+
|
|
33
|
+
public int nBuildPending
|
|
34
|
+
{
|
|
35
|
+
get
|
|
36
|
+
{
|
|
37
|
+
if ((buildRQ != null) && !buildRQ.isDifferentSession) return listBuild.Count(t => t.enable);
|
|
38
|
+
|
|
39
|
+
StopBuild();
|
|
40
|
+
return 0;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
internal static int SecondsTS => (int)(DateTime.Now - new DateTime(2010, 1, 1)).TotalSeconds;
|
|
45
|
+
public void Lock()
|
|
46
|
+
{
|
|
47
|
+
_lockCount++;
|
|
48
|
+
}
|
|
49
|
+
public void Unlock()
|
|
50
|
+
{
|
|
51
|
+
_lockCount--;
|
|
52
|
+
if ((_lockCount == 0) && (_buildInfo != null)) ExportBuild(_buildInfo);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
public void StopBuild()
|
|
56
|
+
{
|
|
57
|
+
for (var i = 0; i < listBuild.Count; i++)
|
|
58
|
+
{
|
|
59
|
+
listBuild[i].enable = false;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
public void ProcessBuild()
|
|
64
|
+
{
|
|
65
|
+
BuildTarget cTarget = EditorUserBuildSettings.activeBuildTarget;
|
|
66
|
+
|
|
67
|
+
for (var i = 0; i < listBuild.Count; i++)
|
|
68
|
+
{
|
|
69
|
+
BuildInfo item = listBuild[i];
|
|
70
|
+
if (!item.enable) continue;
|
|
71
|
+
|
|
72
|
+
if (item.target != cTarget) continue;
|
|
73
|
+
|
|
74
|
+
item.enable = false; // already build
|
|
75
|
+
Build(item);
|
|
76
|
+
return; // only do one build at a time
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
for (var i = 0; i < listBuild.Count; i++)
|
|
80
|
+
{
|
|
81
|
+
BuildInfo item = listBuild[i];
|
|
82
|
+
if (!item.enable) continue;
|
|
83
|
+
|
|
84
|
+
switch (item.target)
|
|
85
|
+
{
|
|
86
|
+
case BuildTarget.Android:
|
|
87
|
+
EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTargetGroup.Android, BuildTarget.Android);
|
|
88
|
+
return; // only do one build at a time
|
|
89
|
+
|
|
90
|
+
case BuildTarget.iOS:
|
|
91
|
+
EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTargetGroup.iOS, BuildTarget.iOS);
|
|
92
|
+
return; // only do one build at a time
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
private void RemoveUnusedAssets()
|
|
99
|
+
{
|
|
100
|
+
AssetDatabase.StartAssetEditing();
|
|
101
|
+
for (var i = 0; i < listUnused.Count; i++)
|
|
102
|
+
{
|
|
103
|
+
if (listUnused[i] == null) continue;
|
|
104
|
+
string path = AssetDatabase.GetAssetPath(listUnused[i]);
|
|
105
|
+
AssetDatabase.DeleteAsset(path);
|
|
106
|
+
}
|
|
107
|
+
AssetDatabase.StopAssetEditing();
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
public void Build(BuildInfo info)
|
|
111
|
+
{
|
|
112
|
+
DryRun(info);
|
|
113
|
+
|
|
114
|
+
if (_lockCount == 0)
|
|
115
|
+
{
|
|
116
|
+
ExportBuild(info);
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
_buildInfo = info;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
public void EnableBuildForTarget(BuildTarget target, bool updateBuildNumber = true)
|
|
124
|
+
{
|
|
125
|
+
for (var i = 0; i < listBuild.Count; i++)
|
|
126
|
+
{
|
|
127
|
+
BuildInfo b = listBuild[i];
|
|
128
|
+
b.enable = b.target == target;
|
|
129
|
+
|
|
130
|
+
if (updateBuildNumber && (b.target == target)) b.buildNumber++;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
EditorUtility.SetDirty(this);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
public void DryRun(BuildInfo info)
|
|
137
|
+
{
|
|
138
|
+
if (string.IsNullOrEmpty(buildFolder)) buildFolder = DEFAULT_BUILD_FOLDER;
|
|
139
|
+
|
|
140
|
+
var buildDir = new DirectoryInfo(buildFolder);
|
|
141
|
+
if (!buildDir.Exists) Directory.CreateDirectory(buildDir.FullName);
|
|
142
|
+
|
|
143
|
+
// Check for existed build with the same name
|
|
144
|
+
if (info.overwrite == false)
|
|
145
|
+
{
|
|
146
|
+
if (info.target == BuildTarget.Android)
|
|
147
|
+
{
|
|
148
|
+
string[] apkNames = info.GetAPKNames(buildFolder);
|
|
149
|
+
for (var i = 0; i < apkNames.Length; i++)
|
|
150
|
+
{
|
|
151
|
+
string item = apkNames[i];
|
|
152
|
+
if (!File.Exists(item)) continue;
|
|
153
|
+
Debug.LogWarning("Exporting file existed! " + item);
|
|
154
|
+
|
|
155
|
+
// return;
|
|
156
|
+
}
|
|
157
|
+
} else
|
|
158
|
+
{
|
|
159
|
+
string fullBuildPath = info.fullBuildPath(buildFolder);
|
|
160
|
+
if (Directory.Exists(fullBuildPath))
|
|
161
|
+
{
|
|
162
|
+
Debug.LogWarning("Exporting target existed! " + fullBuildPath);
|
|
163
|
+
EditorUtility.RevealInFinder(fullBuildPath);
|
|
164
|
+
|
|
165
|
+
// return;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
RemoveUnusedAssets();
|
|
171
|
+
if (info.target == BuildTarget.Android) keystore.Write();
|
|
172
|
+
|
|
173
|
+
info.Write();
|
|
174
|
+
info.PreprocessBuild(buildFolder);
|
|
175
|
+
|
|
176
|
+
// write customized icon, if any
|
|
177
|
+
if ((icon != null) && (info.buildIcon != null) && (info.buildIcon != icon))
|
|
178
|
+
{
|
|
179
|
+
string p1 = AssetDatabase.GetAssetPath(info.buildIcon);
|
|
180
|
+
string p2 = AssetDatabase.GetAssetPath(icon);
|
|
181
|
+
byte[] bytes = File.ReadAllBytes(p1);
|
|
182
|
+
File.WriteAllBytes(p2, bytes);
|
|
183
|
+
|
|
184
|
+
// force refresh
|
|
185
|
+
AssetDatabase.ImportAsset(p2, ImportAssetOptions.ForceSynchronousImport);
|
|
186
|
+
RepaintAll();
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
_lockCount = 0;
|
|
190
|
+
if (beforeBuild != null) beforeBuild.Invoke();
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
private static void RepaintAll()
|
|
194
|
+
{
|
|
195
|
+
UnityObject[] windows = Resources.FindObjectsOfTypeAll(typeof(EditorWindow));
|
|
196
|
+
if (windows == null || windows.Length <= 0) return;
|
|
197
|
+
|
|
198
|
+
for (var i = 0; i < windows.Length; i++)
|
|
199
|
+
{
|
|
200
|
+
var w = windows[i] as EditorWindow;
|
|
201
|
+
if (w != null) w.Repaint();
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
private void RunPostBuild()
|
|
206
|
+
{
|
|
207
|
+
listBuild[0].buildNumber++;
|
|
208
|
+
EditorUtility.SetDirty(this);
|
|
209
|
+
AssetDatabase.SaveAssets();
|
|
210
|
+
// RunPostBuildSH(listBuild[0]);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
// private void RunPostBuildSH(BuildInfo info)
|
|
214
|
+
// {
|
|
215
|
+
// if (shTemplate == null) return;
|
|
216
|
+
//
|
|
217
|
+
// string shPath = ExternalProcessUtils.FileFromTemplate(
|
|
218
|
+
// "git-post-build.sh", shTemplate.text,
|
|
219
|
+
// "{{TEMPLATE_PROJECT_PATH}}", Application.dataPath.Replace("/Assets", string.Empty),
|
|
220
|
+
// "{{TEMPLATE_TAG}}", $"{info.projectId}/v{info.buildVersion}_b{info.buildNumber}",
|
|
221
|
+
// "{{TEMPLATE_BRANCH}}", $"build/v{info.buildVersion}_b{info.buildNumber}",
|
|
222
|
+
// "{{TEMPLATE_BUILD_ASSET}}", $"{AssetDatabase.GetAssetPath(this)}"
|
|
223
|
+
// );
|
|
224
|
+
//
|
|
225
|
+
// // Run & Lock Unity until git finish
|
|
226
|
+
// ExternalProcessUtils.Run(shPath, true);
|
|
227
|
+
// }
|
|
228
|
+
|
|
229
|
+
private void ExportBuild(BuildInfo info)
|
|
230
|
+
{
|
|
231
|
+
string fullBuildPath = info.fullBuildPath(buildFolder);
|
|
232
|
+
BuildPipeline.BuildPlayer(GetScenes(), fullBuildPath, info.target, BuildOptions.None);
|
|
233
|
+
info.PostProcessBuild(buildFolder);
|
|
234
|
+
|
|
235
|
+
// if (buildRQ.willRunSHPostBuild)
|
|
236
|
+
// {
|
|
237
|
+
// // Run once per build request
|
|
238
|
+
// buildRQ.willRunSHPostBuild = false;
|
|
239
|
+
// RunPostBuildSH(info);
|
|
240
|
+
// }
|
|
241
|
+
|
|
242
|
+
if (nBuildPending > 0)
|
|
243
|
+
{
|
|
244
|
+
ProcessBuild();
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
EditorUtility.RevealInFinder(fullBuildPath);
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
internal static string[] GetScenes()
|
|
252
|
+
{
|
|
253
|
+
return EditorBuildSettings.scenes.Where(s => s.enabled).Select(s => s.path).ToArray();
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
internal static void DrawRect(Rect rect, Color c)
|
|
257
|
+
{
|
|
258
|
+
Color bgColor = GUI.color;
|
|
259
|
+
GUI.color = c;
|
|
260
|
+
GUI.DrawTexture(rect, Texture2D.whiteTexture, ScaleMode.StretchToFill, false);
|
|
261
|
+
GUI.color = bgColor;
|
|
262
|
+
}
|
|
263
|
+
[Serializable] public class BuildRequestTS
|
|
264
|
+
{
|
|
265
|
+
public int processId;
|
|
266
|
+
public string machineId;
|
|
267
|
+
public string projectPath;
|
|
268
|
+
public bool willRunSHPostBuild = true;
|
|
269
|
+
|
|
270
|
+
public bool isDifferentSession
|
|
271
|
+
{
|
|
272
|
+
get
|
|
273
|
+
{
|
|
274
|
+
if (machineId != SystemInfo.deviceUniqueIdentifier)
|
|
275
|
+
|
|
276
|
+
//Debug.LogWarning("Different device");
|
|
277
|
+
return true;
|
|
278
|
+
|
|
279
|
+
var currentProcess = Process.GetCurrentProcess();
|
|
280
|
+
if (processId != currentProcess.Id)
|
|
281
|
+
|
|
282
|
+
//Debug.LogWarning("Different process ID");
|
|
283
|
+
return true; // Changed process id
|
|
284
|
+
|
|
285
|
+
if (projectPath != Application.dataPath)
|
|
286
|
+
|
|
287
|
+
//Debug.LogWarning("Different project path");
|
|
288
|
+
return true; // Changed project
|
|
289
|
+
|
|
290
|
+
return false;
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
public static BuildRequestTS Generate() //bool runGit
|
|
295
|
+
{
|
|
296
|
+
var currentProcess = Process.GetCurrentProcess();
|
|
297
|
+
|
|
298
|
+
return new BuildRequestTS
|
|
299
|
+
{
|
|
300
|
+
machineId = SystemInfo.deviceUniqueIdentifier,
|
|
301
|
+
processId = currentProcess.Id,
|
|
302
|
+
projectPath = Application.dataPath,
|
|
303
|
+
// willRunSHPostBuild = runGit
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
[Serializable] public class BuildInfo
|
|
308
|
+
{
|
|
309
|
+
public string projectId;
|
|
310
|
+
public string productName;
|
|
311
|
+
public string packageName;
|
|
312
|
+
|
|
313
|
+
public Texture2D buildIcon;
|
|
314
|
+
public BuildTarget target;
|
|
315
|
+
|
|
316
|
+
public bool isAAB;
|
|
317
|
+
public bool splitAPK = true;
|
|
318
|
+
public bool overwrite = true;
|
|
319
|
+
public string buildVersion;
|
|
320
|
+
public int buildNumber;
|
|
321
|
+
|
|
322
|
+
// Android options
|
|
323
|
+
public bool enable;
|
|
324
|
+
|
|
325
|
+
public bool isAndroid => target == BuildTarget.Android;
|
|
326
|
+
public bool isIOS => target == BuildTarget.iOS;
|
|
327
|
+
|
|
328
|
+
public string buildName => $"{projectId}_v{buildVersion}_b{buildNumber}";
|
|
329
|
+
|
|
330
|
+
public void PreprocessBuild(string buildFolder)
|
|
331
|
+
{
|
|
332
|
+
AssetDatabase.SaveAssets();
|
|
333
|
+
GC.Collect();
|
|
334
|
+
Resources.UnloadUnusedAssets();
|
|
335
|
+
EditorUtility.UnloadUnusedAssetsImmediate();
|
|
336
|
+
|
|
337
|
+
PlayerSettings.bundleVersion = buildVersion;
|
|
338
|
+
|
|
339
|
+
if (isAndroid)
|
|
340
|
+
{
|
|
341
|
+
PlayerSettings.Android.bundleVersionCode = buildNumber;
|
|
342
|
+
PlayerSettings.Android.buildApkPerCpuArchitecture = splitAPK;
|
|
343
|
+
PlayerSettings.Android.targetArchitectures = AndroidArchitecture.All;
|
|
344
|
+
|
|
345
|
+
EditorUserBuildSettings.buildAppBundle = isAAB;
|
|
346
|
+
EditorUserBuildSettings.exportAsGoogleAndroidProject = false;
|
|
347
|
+
EditorUserBuildSettings.androidCreateSymbols = AndroidCreateSymbols.Disabled;
|
|
348
|
+
|
|
349
|
+
string[] listAPKNames = GetAPKNames(buildFolder);
|
|
350
|
+
|
|
351
|
+
for (var i = 0; i < listAPKNames.Length; i++)
|
|
352
|
+
{
|
|
353
|
+
string apkName = listAPKNames[i];
|
|
354
|
+
string tempName = apkName.Replace(buildName, Application.productName);
|
|
355
|
+
|
|
356
|
+
if (File.Exists(tempName)) File.Delete(tempName); // always delete temp file no matter what
|
|
357
|
+
if (overwrite && File.Exists(apkName)) File.Delete(apkName);
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
return;
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
if (isIOS)
|
|
364
|
+
{
|
|
365
|
+
PlayerSettings.iOS.buildNumber = buildNumber.ToString();
|
|
366
|
+
if (!overwrite) return;
|
|
367
|
+
|
|
368
|
+
string path = fullBuildPath(buildFolder);
|
|
369
|
+
if (Directory.Exists(path)) Directory.Delete(path, true);
|
|
370
|
+
return;
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
Debug.LogWarning("Unsupported platform: " + target);
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
public string[] GetAPKNames(string buildFolder)
|
|
377
|
+
{
|
|
378
|
+
var buildDir = new DirectoryInfo(buildFolder);
|
|
379
|
+
string fullName = buildDir.FullName;
|
|
380
|
+
|
|
381
|
+
if (isAAB)
|
|
382
|
+
return new[]
|
|
383
|
+
{
|
|
384
|
+
Path.Combine(fullName, buildName + ".aab")
|
|
385
|
+
};
|
|
386
|
+
|
|
387
|
+
if (splitAPK)
|
|
388
|
+
return new[]
|
|
389
|
+
{
|
|
390
|
+
Path.Combine(fullName, buildName + ".arm64-v8a.apk"), Path.Combine(fullName, buildName + ".armeabi-v7a.apk")
|
|
391
|
+
};
|
|
392
|
+
|
|
393
|
+
return new[]
|
|
394
|
+
{
|
|
395
|
+
Path.Combine(fullName, buildName + ".apk")
|
|
396
|
+
};
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
public void PostProcessBuild(string buildFolder)
|
|
400
|
+
{
|
|
401
|
+
if (target != BuildTarget.Android) return;
|
|
402
|
+
if (isAAB) return;
|
|
403
|
+
|
|
404
|
+
// var productName = Application.productName;
|
|
405
|
+
string[] listAPKNames = GetAPKNames(buildFolder);
|
|
406
|
+
|
|
407
|
+
for (var i = 0; i < listAPKNames.Length; i++)
|
|
408
|
+
{
|
|
409
|
+
string apkName = listAPKNames[i];
|
|
410
|
+
string tempName = apkName.Replace(buildName, productName);
|
|
411
|
+
|
|
412
|
+
if (!File.Exists(tempName)) continue;
|
|
413
|
+
File.Move(tempName, apkName);
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
public string fullBuildPath(string buildFolder)
|
|
418
|
+
{
|
|
419
|
+
if (buildFolder.EndsWith("/"))
|
|
420
|
+
|
|
421
|
+
// remove last slash
|
|
422
|
+
buildFolder = buildFolder.Substring(0, buildFolder.Length - 1);
|
|
423
|
+
|
|
424
|
+
var buildDir = new DirectoryInfo(buildFolder);
|
|
425
|
+
|
|
426
|
+
if (isAndroid)
|
|
427
|
+
{
|
|
428
|
+
if (isAAB) return Path.Combine(buildDir.FullName, buildName + ".aab");
|
|
429
|
+
if (splitAPK) return buildDir.FullName;
|
|
430
|
+
return Path.Combine(buildDir.FullName, buildName + ".apk");
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
return Path.Combine(buildDir.FullName, "XCode_" + buildName);
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
public BuildInfo Read()
|
|
437
|
+
{
|
|
438
|
+
buildVersion = PlayerSettings.bundleVersion;
|
|
439
|
+
productName = PlayerSettings.productName;
|
|
440
|
+
|
|
441
|
+
if (isAndroid)
|
|
442
|
+
{
|
|
443
|
+
buildNumber = PlayerSettings.Android.bundleVersionCode;
|
|
444
|
+
packageName = PlayerSettings.GetApplicationIdentifier(BuildTargetGroup.Android);
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
if (isIOS)
|
|
448
|
+
{
|
|
449
|
+
int.TryParse(PlayerSettings.iOS.buildNumber, out buildNumber);
|
|
450
|
+
packageName = PlayerSettings.GetApplicationIdentifier(BuildTargetGroup.iOS);
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
return this;
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
public void Write()
|
|
457
|
+
{
|
|
458
|
+
PlayerSettings.bundleVersion = buildVersion;
|
|
459
|
+
PlayerSettings.productName = productName;
|
|
460
|
+
|
|
461
|
+
if (isAndroid)
|
|
462
|
+
{
|
|
463
|
+
PlayerSettings.Android.bundleVersionCode = buildNumber;
|
|
464
|
+
PlayerSettings.SetApplicationIdentifier(BuildTargetGroup.Android, packageName);
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
if (isIOS)
|
|
468
|
+
{
|
|
469
|
+
PlayerSettings.iOS.buildNumber = buildNumber.ToString();
|
|
470
|
+
PlayerSettings.SetApplicationIdentifier(BuildTargetGroup.iOS, packageName);
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
EditorApplication.RepaintProjectWindow();
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
public void IncreaseVersion()
|
|
477
|
+
{
|
|
478
|
+
buildNumber++;
|
|
479
|
+
if (string.IsNullOrEmpty(buildVersion)) buildVersion = "1.0.0";
|
|
480
|
+
|
|
481
|
+
string[] arr = buildVersion.Split('.');
|
|
482
|
+
int last = int.Parse(arr[2]);
|
|
483
|
+
last++;
|
|
484
|
+
|
|
485
|
+
arr[2] = last.ToString();
|
|
486
|
+
buildVersion = string.Join(".", arr);
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
[Serializable] public class KeystoreInfo
|
|
491
|
+
{
|
|
492
|
+
public string path = "AmaGDK/Store/project.keystore";
|
|
493
|
+
public string alias = "alias";
|
|
494
|
+
public string keystorePassword = "123456789";
|
|
495
|
+
public string aliasPassword = "123456789";
|
|
496
|
+
|
|
497
|
+
public void Write()
|
|
498
|
+
{
|
|
499
|
+
// Must use absolute path or else gradle build fail
|
|
500
|
+
var keystoreFI = new FileInfo(path);
|
|
501
|
+
PlayerSettings.Android.keystoreName = keystoreFI.FullName;
|
|
502
|
+
PlayerSettings.keystorePass = keystorePassword;
|
|
503
|
+
PlayerSettings.Android.keyaliasPass = aliasPassword;
|
|
504
|
+
PlayerSettings.Android.keyaliasName = alias;
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
|
|
510
|
+
[InitializeOnLoad]
|
|
511
|
+
internal class GDKAutoBuildHelper
|
|
512
|
+
{
|
|
513
|
+
private static GDKAutoBuild build;
|
|
514
|
+
static GDKAutoBuildHelper()
|
|
515
|
+
{
|
|
516
|
+
EditorApplication.update -= Update;
|
|
517
|
+
EditorApplication.update += Update;
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
private static void Update()
|
|
521
|
+
{
|
|
522
|
+
if (EditorApplication.isCompiling || EditorApplication.isUpdating) return;
|
|
523
|
+
|
|
524
|
+
if (EditorApplication.isPlaying || EditorApplication.isPlayingOrWillChangePlaymode)
|
|
525
|
+
{
|
|
526
|
+
if (build != null) build.StopBuild();
|
|
527
|
+
EditorApplication.update -= Update;
|
|
528
|
+
return;
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
if (build == null)
|
|
532
|
+
{
|
|
533
|
+
string[] guids = AssetDatabase.FindAssets("t:" + nameof(GDKAutoBuild)); //FindAssets uses tags check documentation for more info
|
|
534
|
+
if (guids.Length == 0)
|
|
535
|
+
{
|
|
536
|
+
EditorApplication.update -= Update;
|
|
537
|
+
return;
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
string path = AssetDatabase.GUIDToAssetPath(guids[0]);
|
|
541
|
+
build = AssetDatabase.LoadAssetAtPath<GDKAutoBuild>(path);
|
|
542
|
+
if (build == null)
|
|
543
|
+
{
|
|
544
|
+
EditorApplication.update -= Update;
|
|
545
|
+
return;
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
EditorApplication.update -= Update;
|
|
550
|
+
|
|
551
|
+
//check if timeStamp is valid
|
|
552
|
+
if (build.nBuildPending == 0) return;
|
|
553
|
+
|
|
554
|
+
build.ProcessBuild();
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
|
|
558
|
+
// [MenuItem("Window/AmaGDK/Build/Select Build Asset &#b", false, 10)]
|
|
559
|
+
public static void SelectBuild()
|
|
560
|
+
{
|
|
561
|
+
string[] arr = AssetDatabase.FindAssets("t:" + nameof(GDKAutoBuild));
|
|
562
|
+
|
|
563
|
+
if (arr.Length == 0)
|
|
564
|
+
{
|
|
565
|
+
Debug.LogWarning("There are no Build asset in the project!");
|
|
566
|
+
return;
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
// if (arr.Length > 1)
|
|
570
|
+
// {
|
|
571
|
+
// Debug.LogWarning("There are [" + arr.Length + "] Build assets in the project!");
|
|
572
|
+
// }
|
|
573
|
+
|
|
574
|
+
string path = AssetDatabase.GUIDToAssetPath(arr[0]);
|
|
575
|
+
var obj = AssetDatabase.LoadAssetAtPath<UnityObject>(path);
|
|
576
|
+
Selection.activeObject = obj;
|
|
577
|
+
EditorGUIUtility.PingObject(obj);
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
private static GDKAutoBuild FindAutoBuildAssets(string name = null, bool allowFallback = false)
|
|
581
|
+
{
|
|
582
|
+
string[] arr = AssetDatabase.FindAssets("t:" + nameof(GDKAutoBuild));
|
|
583
|
+
if (arr.Length == 0)
|
|
584
|
+
{
|
|
585
|
+
Debug.LogWarning("There are no Build asset in the project!");
|
|
586
|
+
return null;
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
for (var i = 0; i < arr.Length; i++)
|
|
590
|
+
{
|
|
591
|
+
string path = AssetDatabase.GUIDToAssetPath(arr[i]).Replace("\\", "/");
|
|
592
|
+
if (string.IsNullOrEmpty(name)) return AssetDatabase.LoadAssetAtPath<GDKAutoBuild>(path);
|
|
593
|
+
|
|
594
|
+
string fileName = Path.GetFileName(path);
|
|
595
|
+
if (fileName.ToLower().Contains(name.ToLower())) return AssetDatabase.LoadAssetAtPath<GDKAutoBuild>(path);
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
if (!allowFallback) return null;
|
|
599
|
+
|
|
600
|
+
// Fall back to the first one
|
|
601
|
+
string path0 = AssetDatabase.GUIDToAssetPath(arr[0]).Replace("\\", "/");
|
|
602
|
+
return AssetDatabase.LoadAssetAtPath<GDKAutoBuild>(path0);
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
// [MenuItem("Window/AmaGDK/Build/Android", false, 50)] public static void BuildAndroid() { BuildAndroid(false); }
|
|
606
|
+
// [MenuItem("Window/AmaGDK/Build/iOS", false, 51)] public static void BuildIOS() { BuildIOS(false); }
|
|
607
|
+
// [MenuItem("Window/AmaGDK/Build/Android - Release", false, 90)] public static void BuildAndroidRelease() { BuildAndroid(true); }
|
|
608
|
+
// [MenuItem("Window/AmaGDK/Build/iOS - Release", false, 91)] public static void BuildIOSRelease() { BuildIOS(true); }
|
|
609
|
+
|
|
610
|
+
|
|
611
|
+
private static void BuildAndroid(bool isRelease)
|
|
612
|
+
{
|
|
613
|
+
GDKAutoBuild buildAsset = FindAutoBuildAssets("android");
|
|
614
|
+
if (buildAsset == null)
|
|
615
|
+
{
|
|
616
|
+
Debug.LogWarning("Build Asset for Android not found!");
|
|
617
|
+
return;
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
buildAsset.EnableBuildForTarget(BuildTarget.Android);
|
|
621
|
+
buildAsset.buildRQ = GDKAutoBuild.BuildRequestTS.Generate();// isRelease
|
|
622
|
+
buildAsset.ProcessBuild();
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
private static void BuildIOS(bool isRelease)
|
|
626
|
+
{
|
|
627
|
+
GDKAutoBuild buildAsset = FindAutoBuildAssets("ios");
|
|
628
|
+
if (buildAsset == null)
|
|
629
|
+
{
|
|
630
|
+
Debug.LogWarning("Build Asset for iOS not found!");
|
|
631
|
+
return;
|
|
632
|
+
}
|
|
633
|
+
buildAsset.EnableBuildForTarget(BuildTarget.iOS);
|
|
634
|
+
buildAsset.buildRQ = GDKAutoBuild.BuildRequestTS.Generate(); //isRelease
|
|
635
|
+
buildAsset.ProcessBuild();
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
[CustomEditor(typeof(GDKAutoBuild))]
|
|
640
|
+
public class GDKAutoBuildEditor : UnityEditor.Editor
|
|
641
|
+
{
|
|
642
|
+
public int bIndex;
|
|
643
|
+
public string path;
|
|
644
|
+
public bool drawDefault;
|
|
645
|
+
|
|
646
|
+
public GUIStyle productNameStyle;
|
|
647
|
+
public GUIStyle projectStyle;
|
|
648
|
+
|
|
649
|
+
private string helpInfo;
|
|
650
|
+
|
|
651
|
+
private void Init()
|
|
652
|
+
{
|
|
653
|
+
productNameStyle = new GUIStyle(EditorStyles.largeLabel)
|
|
654
|
+
{
|
|
655
|
+
alignment = TextAnchor.MiddleCenter,
|
|
656
|
+
fontSize = 32
|
|
657
|
+
};
|
|
658
|
+
|
|
659
|
+
projectStyle = new GUIStyle(EditorStyles.miniLabel)
|
|
660
|
+
{
|
|
661
|
+
alignment = TextAnchor.MiddleCenter
|
|
662
|
+
};
|
|
663
|
+
|
|
664
|
+
path = Application.dataPath;
|
|
665
|
+
List<string> arr = path.Split('/').ToList();
|
|
666
|
+
arr.RemoveAt(arr.Count - 1);
|
|
667
|
+
|
|
668
|
+
if (arr.Count > 3) arr.RemoveRange(0, arr.Count - 3);
|
|
669
|
+
|
|
670
|
+
path = string.Join("/", arr);
|
|
671
|
+
}
|
|
672
|
+
public override void OnInspectorGUI()
|
|
673
|
+
{
|
|
674
|
+
var ab = (GDKAutoBuild)target;
|
|
675
|
+
if (ab == null) return;
|
|
676
|
+
|
|
677
|
+
if (productNameStyle == null) Init();
|
|
678
|
+
|
|
679
|
+
GUILayout.Label(PlayerSettings.productName, productNameStyle);
|
|
680
|
+
|
|
681
|
+
Rect r0 = GUILayoutUtility.GetRect(0, Screen.width, 16f, 16f);
|
|
682
|
+
r0.xMin = 0;
|
|
683
|
+
r0.xMax += 16f;
|
|
684
|
+
GDKAutoBuild.DrawRect(r0, new Color32(20, 20, 20, 255));
|
|
685
|
+
|
|
686
|
+
if ((Event.current.type == EventType.MouseUp) && r0.Contains(Event.current.mousePosition))
|
|
687
|
+
{
|
|
688
|
+
var fullPath = new DirectoryInfo(ab.buildFolder);
|
|
689
|
+
EditorUtility.RevealInFinder(fullPath.FullName);
|
|
690
|
+
Event.current.Use();
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
GUI.Label(r0, path, projectStyle);
|
|
694
|
+
EditorGUILayout.Space();
|
|
695
|
+
|
|
696
|
+
if (string.IsNullOrEmpty(helpInfo)) helpInfo = $"\nPackageName:\t{PlayerSettings.applicationIdentifier}\nTargetPlatform:\t{EditorUserBuildSettings.activeBuildTarget}\n";
|
|
697
|
+
EditorGUILayout.HelpBox(helpInfo, MessageType.Info);
|
|
698
|
+
Rect rect = GUILayoutUtility.GetLastRect();
|
|
699
|
+
if ((Event.current.type == EventType.MouseUp) && rect.Contains(Event.current.mousePosition))
|
|
700
|
+
{
|
|
701
|
+
Event.current.Use();
|
|
702
|
+
helpInfo = null;
|
|
703
|
+
Repaint();
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
drawDefault = GUILayout.Toggle(drawDefault, "Draw default");
|
|
707
|
+
if (drawDefault) DrawDefaultInspector();
|
|
708
|
+
|
|
709
|
+
EditorGUILayout.Space();
|
|
710
|
+
|
|
711
|
+
int max = ab.listBuild.Count;
|
|
712
|
+
if (max == 0)
|
|
713
|
+
{
|
|
714
|
+
EditorGUILayout.HelpBox("No BuildInfo!", MessageType.Warning);
|
|
715
|
+
|
|
716
|
+
if (GUILayout.Button("Create Default"))
|
|
717
|
+
{
|
|
718
|
+
new GDKAutoBuild.BuildInfo().Read();
|
|
719
|
+
|
|
720
|
+
ab.listBuild = new List<GDKAutoBuild.BuildInfo>
|
|
721
|
+
{
|
|
722
|
+
new GDKAutoBuild.BuildInfo
|
|
723
|
+
{
|
|
724
|
+
target = BuildTarget.Android, isAAB = false, splitAPK = true
|
|
725
|
+
}.Read(),
|
|
726
|
+
new GDKAutoBuild.BuildInfo
|
|
727
|
+
{
|
|
728
|
+
target = BuildTarget.Android, isAAB = true, splitAPK = true
|
|
729
|
+
}.Read(),
|
|
730
|
+
new GDKAutoBuild.BuildInfo
|
|
731
|
+
{
|
|
732
|
+
target = BuildTarget.iOS, isAAB = true, splitAPK = true
|
|
733
|
+
}.Read()
|
|
734
|
+
};
|
|
735
|
+
}
|
|
736
|
+
return;
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
serializedObject.Update();
|
|
740
|
+
SerializedProperty prop = serializedObject.FindProperty($"listBuild.Array.data[{bIndex}]");
|
|
741
|
+
prop.isExpanded = true;
|
|
742
|
+
|
|
743
|
+
GDKAutoBuild.BuildInfo info = ab.listBuild[bIndex];
|
|
744
|
+
|
|
745
|
+
EditorGUI.BeginChangeCheck();
|
|
746
|
+
{
|
|
747
|
+
EditorGUILayout.PropertyField(prop, true);
|
|
748
|
+
}
|
|
749
|
+
if (EditorGUI.EndChangeCheck()) serializedObject.ApplyModifiedProperties();
|
|
750
|
+
|
|
751
|
+
Rect r = GUILayoutUtility.GetLastRect();
|
|
752
|
+
r.x = 0;
|
|
753
|
+
r.width = Screen.width;
|
|
754
|
+
r.height = 16f;
|
|
755
|
+
|
|
756
|
+
GDKAutoBuild.DrawRect(r, new Color32(20, 20, 20, 255));
|
|
757
|
+
|
|
758
|
+
r.xMin += 12f;
|
|
759
|
+
GUI.Label(r, info.buildName);
|
|
760
|
+
|
|
761
|
+
if ((ab.icon != null) && (ab.icon == info.buildIcon)) EditorGUILayout.HelpBox("Build Icon must be different with the template icon (which will be overwritten)", MessageType.Error);
|
|
762
|
+
|
|
763
|
+
GUILayout.BeginHorizontal();
|
|
764
|
+
{
|
|
765
|
+
if (GUILayout.Button("Read")) info.Read();
|
|
766
|
+
|
|
767
|
+
if (GUILayout.Button("Write")) info.Write();
|
|
768
|
+
|
|
769
|
+
if (GUILayout.Button("+")) info.IncreaseVersion();
|
|
770
|
+
}
|
|
771
|
+
GUILayout.EndHorizontal();
|
|
772
|
+
|
|
773
|
+
if (GUILayout.Button("Dry Run"))
|
|
774
|
+
{
|
|
775
|
+
ab.DryRun(info);
|
|
776
|
+
helpInfo = null;
|
|
777
|
+
Repaint();
|
|
778
|
+
}
|
|
779
|
+
|
|
780
|
+
bIndex = EditorGUILayout.IntSlider(bIndex, 0, max - 1);
|
|
781
|
+
|
|
782
|
+
var nBuilds = 0;
|
|
783
|
+
for (var i = 0; i < ab.listBuild.Count; i++)
|
|
784
|
+
{
|
|
785
|
+
GDKAutoBuild.BuildInfo item = ab.listBuild[i];
|
|
786
|
+
|
|
787
|
+
if (!item.enable) continue;
|
|
788
|
+
nBuilds++;
|
|
789
|
+
|
|
790
|
+
string hint = item.target == BuildTarget.Android
|
|
791
|
+
? $"{string.Join("\n", item.GetAPKNames(ab.buildFolder))}"
|
|
792
|
+
: item.fullBuildPath(ab.buildFolder);
|
|
793
|
+
|
|
794
|
+
EditorGUILayout.HelpBox(hint, MessageType.Info);
|
|
795
|
+
}
|
|
796
|
+
|
|
797
|
+
if (nBuilds == 0) return;
|
|
798
|
+
|
|
799
|
+
GUILayout.BeginHorizontal();
|
|
800
|
+
{
|
|
801
|
+
if (GUILayout.Button("Build"))
|
|
802
|
+
{
|
|
803
|
+
ab.buildRQ = GDKAutoBuild.BuildRequestTS.Generate(); //ab.runGitPostBuild
|
|
804
|
+
ab.ProcessBuild();
|
|
805
|
+
}
|
|
806
|
+
|
|
807
|
+
if (GUILayout.Button("Stop")) ab.StopBuild();
|
|
808
|
+
}
|
|
809
|
+
GUILayout.EndHorizontal();
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
|
|
813
|
+
|
|
814
|
+
public class ExternalProcessUtils
|
|
815
|
+
{
|
|
816
|
+
public static string FileFromTemplate(string fileName, string source, params string[] tokens)
|
|
817
|
+
{
|
|
818
|
+
for (var i = 0; i < tokens.Length; i += 2)
|
|
819
|
+
{
|
|
820
|
+
source = source.Replace(tokens[i], tokens[i + 1]);
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
string filePath = Application.dataPath.Replace("/Assets", "/" + fileName);
|
|
824
|
+
|
|
825
|
+
// Debug.LogWarning("FilePath: " + filePath);
|
|
826
|
+
File.WriteAllText(filePath, source);
|
|
827
|
+
return filePath;
|
|
828
|
+
}
|
|
829
|
+
|
|
830
|
+
// public static void GitResetRepo()
|
|
831
|
+
// {
|
|
832
|
+
// RunCMD("git reset --hard | git clean -df");
|
|
833
|
+
// }
|
|
834
|
+
|
|
835
|
+
public static void RunCMD(string cmd)
|
|
836
|
+
{
|
|
837
|
+
try
|
|
838
|
+
{
|
|
839
|
+
var startInfo = new ProcessStartInfo
|
|
840
|
+
{
|
|
841
|
+
FileName = "/bin/bash",
|
|
842
|
+
Arguments = $"-c \" {cmd} \" ",
|
|
843
|
+
CreateNoWindow = true
|
|
844
|
+
};
|
|
845
|
+
|
|
846
|
+
var proc = new Process
|
|
847
|
+
{
|
|
848
|
+
StartInfo = startInfo
|
|
849
|
+
};
|
|
850
|
+
|
|
851
|
+
proc.Start();
|
|
852
|
+
proc.WaitForExit();
|
|
853
|
+
} catch (Exception e)
|
|
854
|
+
{
|
|
855
|
+
Debug.LogWarning(e);
|
|
856
|
+
}
|
|
857
|
+
}
|
|
858
|
+
|
|
859
|
+
public static void ChmodX(string filePath)
|
|
860
|
+
{
|
|
861
|
+
RunCMD($"chmod +x {filePath}");
|
|
862
|
+
}
|
|
863
|
+
|
|
864
|
+
public static void Run(string filePath, bool waitExit = false)
|
|
865
|
+
{
|
|
866
|
+
ChmodX(filePath);
|
|
867
|
+
|
|
868
|
+
try
|
|
869
|
+
{
|
|
870
|
+
var process = new Process
|
|
871
|
+
{
|
|
872
|
+
EnableRaisingEvents = false,
|
|
873
|
+
StartInfo =
|
|
874
|
+
{
|
|
875
|
+
FileName = filePath,
|
|
876
|
+
UseShellExecute = false,
|
|
877
|
+
RedirectStandardOutput = true,
|
|
878
|
+
RedirectStandardInput = true,
|
|
879
|
+
RedirectStandardError = true
|
|
880
|
+
}
|
|
881
|
+
};
|
|
882
|
+
|
|
883
|
+
process.Start();
|
|
884
|
+
if (waitExit) process.WaitForExit();
|
|
885
|
+
} catch (Exception e)
|
|
886
|
+
{
|
|
887
|
+
Debug.LogWarning(e);
|
|
888
|
+
}
|
|
889
|
+
}
|
|
890
|
+
}
|
|
891
|
+
}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
using System.Collections.Generic;
|
|
2
|
+
using UnityEditor;
|
|
3
|
+
using UnityEngine;
|
|
4
|
+
using System.Linq;
|
|
5
|
+
using UnityEditor.SceneManagement;
|
|
6
|
+
|
|
7
|
+
namespace Amanotes
|
|
8
|
+
{
|
|
9
|
+
internal class GDKProjectCP : EditorWindow
|
|
10
|
+
{
|
|
11
|
+
private static GDKProjectCP _window;
|
|
12
|
+
static Texture2D iconScene;
|
|
13
|
+
static Texture2D iconPlay;
|
|
14
|
+
static Texture2D iconFolder;
|
|
15
|
+
static GUIStyle productNameStyle;
|
|
16
|
+
static string projectPath;
|
|
17
|
+
|
|
18
|
+
private static int activeSceneIndex;
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
[MenuItem("Window/AmaGDK/Project Control Panel")]
|
|
22
|
+
private static void ShowWindow()
|
|
23
|
+
{
|
|
24
|
+
if (_window != null) return;
|
|
25
|
+
|
|
26
|
+
iconScene = AssetPreview.GetMiniTypeThumbnail(typeof(SceneAsset));
|
|
27
|
+
_window = CreateInstance<GDKProjectCP>();
|
|
28
|
+
_window.titleContent = new GUIContent("Project CP", iconScene, "GDK Project Control Panel");
|
|
29
|
+
_window.Show();
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
void Init()
|
|
33
|
+
{
|
|
34
|
+
if (iconScene == null) iconScene = AssetPreview.GetMiniTypeThumbnail(typeof(SceneAsset));
|
|
35
|
+
iconPlay = EditorGUIUtility.FindTexture("PlayButton");
|
|
36
|
+
iconFolder = EditorGUIUtility.FindTexture("Folder Icon");
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
productNameStyle = new GUIStyle(EditorStyles.largeLabel)
|
|
40
|
+
{
|
|
41
|
+
alignment = TextAnchor.MiddleCenter,
|
|
42
|
+
fontSize = 32
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
projectPath = Application.dataPath;
|
|
46
|
+
List<string> arr = projectPath.Split('/').ToList();
|
|
47
|
+
arr.RemoveAt(arr.Count - 1);
|
|
48
|
+
|
|
49
|
+
if (arr.Count > 3)
|
|
50
|
+
{
|
|
51
|
+
arr.RemoveRange(0, arr.Count - 3);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
projectPath = string.Join("/", arr);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
static void DrawBigPlayButton()
|
|
58
|
+
{
|
|
59
|
+
EditorBuildSettingsScene[] scenes = EditorBuildSettings.scenes;
|
|
60
|
+
if (scenes.Length == 0)
|
|
61
|
+
{
|
|
62
|
+
EditorGUILayout.HelpBox("No scene in Build Setting!", MessageType.Warning);
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
EditorBuildSettingsScene scene = scenes[activeSceneIndex];
|
|
67
|
+
|
|
68
|
+
GUILayout.BeginHorizontal();
|
|
69
|
+
{
|
|
70
|
+
EditorGUILayout.Space();
|
|
71
|
+
GUILayout.BeginVertical();
|
|
72
|
+
{
|
|
73
|
+
GUILayout.Space(16);
|
|
74
|
+
GUILayout.Label(scene.path);
|
|
75
|
+
activeSceneIndex = EditorGUILayout.IntSlider(activeSceneIndex, 0, scenes.Length - 1);
|
|
76
|
+
}
|
|
77
|
+
GUILayout.EndVertical();
|
|
78
|
+
if (GUILayout.Button(iconPlay, GUILayout.Width(64f), GUILayout.Height(64f)))
|
|
79
|
+
{
|
|
80
|
+
OpenScene(scene.path, true);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
GUILayout.EndHorizontal();
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
static void OpenScene(string scenePath, bool play)
|
|
87
|
+
{
|
|
88
|
+
if (EditorApplication.isPlaying)
|
|
89
|
+
{
|
|
90
|
+
EditorApplication.isPlaying = false;
|
|
91
|
+
}
|
|
92
|
+
else
|
|
93
|
+
{
|
|
94
|
+
EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo();
|
|
95
|
+
EditorSceneManager.OpenScene(scenePath, OpenSceneMode.Single);
|
|
96
|
+
if (play) EditorApplication.isPlaying = true;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
static void DrawProjectInfo()
|
|
101
|
+
{
|
|
102
|
+
GUILayout.Label(PlayerSettings.productName, productNameStyle);
|
|
103
|
+
|
|
104
|
+
var projectPathContent = new GUIContent(projectPath, iconFolder, "click to open folder");
|
|
105
|
+
|
|
106
|
+
if (GUILayout.Button(projectPathContent, EditorStyles.toolbarButton))
|
|
107
|
+
{
|
|
108
|
+
EditorUtility.RevealInFinder(Application.dataPath);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
static void DrawListScenes()
|
|
113
|
+
{
|
|
114
|
+
EditorBuildSettingsScene[] listScenes = EditorBuildSettings.scenes;
|
|
115
|
+
int n = Mathf.Min(listScenes.Length, listScenes.Length);
|
|
116
|
+
|
|
117
|
+
GUILayout.BeginVertical();
|
|
118
|
+
{
|
|
119
|
+
for (var i = 0; i < n; i++)
|
|
120
|
+
{
|
|
121
|
+
EditorBuildSettingsScene scene = listScenes[i];
|
|
122
|
+
if (!scene.enabled) continue;
|
|
123
|
+
|
|
124
|
+
GUILayout.BeginHorizontal();
|
|
125
|
+
{
|
|
126
|
+
var asset = AssetDatabase.LoadAssetAtPath<SceneAsset>(scene.path);
|
|
127
|
+
|
|
128
|
+
if (GUILayout.Button(iconScene, EditorStyles.toolbarButton, GUILayout.Width(25f)))
|
|
129
|
+
{
|
|
130
|
+
OpenScene(scene.path, false);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
EditorGUILayout.ObjectField(asset, typeof(SceneAsset), false);
|
|
134
|
+
|
|
135
|
+
if (GUILayout.Button(iconPlay, EditorStyles.toolbarButton, GUILayout.Width(25f)))
|
|
136
|
+
{
|
|
137
|
+
OpenScene(scene.path, true);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
GUILayout.EndHorizontal();
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
GUILayout.EndVertical();
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
public void OnGUI()
|
|
148
|
+
{
|
|
149
|
+
if (productNameStyle == null) Init();
|
|
150
|
+
|
|
151
|
+
DrawProjectInfo();
|
|
152
|
+
EditorGUILayout.Space();
|
|
153
|
+
DrawBigPlayButton();
|
|
154
|
+
EditorGUILayout.Space();
|
|
155
|
+
DrawListScenes();
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/Runtime/AmaGDK.Ads.cs
CHANGED
|
@@ -373,6 +373,7 @@ namespace Amanotes.Core.Internal
|
|
|
373
373
|
public int adShowTimeoutInSecs = 5;
|
|
374
374
|
public BannerPosition bannerPosition = BannerPosition.BOTTOM;
|
|
375
375
|
public bool autoLogEvent = true;
|
|
376
|
+
public bool checkInternet = true;
|
|
376
377
|
|
|
377
378
|
public bool enableInterstitial = true;
|
|
378
379
|
public bool enableRewarded = true;
|
|
@@ -710,7 +711,7 @@ namespace Amanotes.Core.Internal
|
|
|
710
711
|
if (_loadState != LoadAdsState.Requesting) StartLoadAd();
|
|
711
712
|
var counter = 0;
|
|
712
713
|
bool? hasInternet = null;
|
|
713
|
-
_instance.StartCoroutine(WebUtils.CheckInternet(result => hasInternet = result));
|
|
714
|
+
if (adConfig.checkInternet) _instance.StartCoroutine(WebUtils.CheckInternet(result => hasInternet = result));
|
|
714
715
|
|
|
715
716
|
var wait1Sec = new WaitForSecondsRealtime(1f);
|
|
716
717
|
while (counter < timeout || timeout == -1)
|
|
@@ -719,7 +720,7 @@ namespace Amanotes.Core.Internal
|
|
|
719
720
|
counter++;
|
|
720
721
|
|
|
721
722
|
// finish checking internet & result is false
|
|
722
|
-
if (hasInternet == false)
|
|
723
|
+
if (adConfig.checkInternet && hasInternet == false)
|
|
723
724
|
{
|
|
724
725
|
Log("[Ad] Stop WaitForAd : No internet!");
|
|
725
726
|
_showState = ShowAdsState.ShowFail;
|
package/Runtime/AmaGDK.cs
CHANGED
|
@@ -39,6 +39,7 @@ namespace Amanotes.Core.Internal
|
|
|
39
39
|
#endif
|
|
40
40
|
|
|
41
41
|
public const string PACKAGE_PATH = BASE_PATH + "Packages/";
|
|
42
|
+
public const string EXTRA_PATH = BASE_PATH + "Extra/";
|
|
42
43
|
public const string AMAGDK_PREFAB = BASE_PATH + "Runtime/AmaGDK.prefab";
|
|
43
44
|
public const string AMAGDK_CONFIG_PACKAGE = PACKAGE_PATH + "AmaGDKConfig.unitypackage";
|
|
44
45
|
|
package/package.json
CHANGED
|
Binary file
|