You've already forked Commercialization.topon
release: 1.4.7
This commit is contained in:
78
Assets/Topon_Adapter/Editor/IAABatchBuildBootstrap.cs
Normal file
78
Assets/Topon_Adapter/Editor/IAABatchBuildBootstrap.cs
Normal file
@@ -0,0 +1,78 @@
|
||||
#if UNITY_EDITOR
|
||||
using System;
|
||||
using System.IO;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
[InitializeOnLoad]
|
||||
public static class IAABatchBuildBootstrap
|
||||
{
|
||||
private const string TaskFilePath = "Temp/iaa-batch-task.txt";
|
||||
private static bool _subscribed;
|
||||
private static bool _taskRunning;
|
||||
|
||||
static IAABatchBuildBootstrap()
|
||||
{
|
||||
if (!Application.isBatchMode)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (_subscribed)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_subscribed = true;
|
||||
EditorApplication.update += ExecutePendingTaskWhenReady;
|
||||
}
|
||||
|
||||
private static void ExecutePendingTaskWhenReady()
|
||||
{
|
||||
if (!Application.isBatchMode || _taskRunning)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var fullPath = Path.GetFullPath(TaskFilePath);
|
||||
if (!File.Exists(fullPath))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (EditorApplication.isCompiling || EditorApplication.isUpdating)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_taskRunning = true;
|
||||
EditorApplication.update -= ExecutePendingTaskWhenReady;
|
||||
|
||||
var task = File.ReadAllText(fullPath).Trim();
|
||||
File.Delete(fullPath);
|
||||
|
||||
try
|
||||
{
|
||||
switch (task)
|
||||
{
|
||||
case "create-sample":
|
||||
IAAAdDebugSampleCreator.CreateOrUpdateSample();
|
||||
break;
|
||||
case "build-apk":
|
||||
IAAAdAndroidBuild.BuildAndroidTestApk();
|
||||
break;
|
||||
default:
|
||||
Debug.LogWarning($"[IAA Batch] Unknown task: {task}");
|
||||
break;
|
||||
}
|
||||
|
||||
EditorApplication.Exit(0);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Debug.LogException(exception);
|
||||
EditorApplication.Exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user