Files
plugin-library/Assets/00.StaryEvoTools/Editor/Build/BuildReport.cs

48 lines
1.6 KiB
C#
Raw Normal View History

2025-07-14 18:32:27 +08:00
using System;
using System.Collections.Generic;
2025-04-14 12:18:19 +08:00
using Stary.Evo.Editor;
using UnityEditor;
using UnityEditor.Build;
using UnityEditor.Callbacks;
2025-07-14 18:26:17 +08:00
using UnityEngine;
2025-04-14 12:18:19 +08:00
2025-08-21 16:42:16 +08:00
namespace Stary.Evo.Editor
2025-04-14 12:18:19 +08:00
{
// 实现接口的方式
public class BuildReport : IPostprocessBuildWithReport, IPreprocessBuildWithReport
{
public int callbackOrder { get; set; }
public void OnPreprocessBuild(UnityEditor.Build.Reporting.BuildReport report)
{
2026-01-07 18:20:13 +08:00
string platform = CustomEditorPrefs.GetString("ChangePlayerSchema");
2025-04-14 12:18:19 +08:00
// build前
2025-07-14 18:32:27 +08:00
if (Enum.Parse<PLayerMode>(platform) == PLayerMode.EDITOR_SIMULATEMODE)
2025-07-14 18:26:17 +08:00
{
int id = EditorUtility.DisplayDialogComplex("提示",
$"当前为[{PLayerMode.EDITOR_SIMULATEMODE}]模式,请选择切换得热更模式!",
2026-01-05 17:58:53 +08:00
$"{PLayerMode.HOST_PLAYMODE}", $"{PLayerMode.HOST_PLAYMODE}", "取消");
2025-04-14 14:40:32 +08:00
2025-07-14 18:26:17 +08:00
switch (id)
{
case 0:
ChangePlayerSchema.SetPlayerMode(PLayerMode.HOST_PLAYMODE);
Debug.Log("切换为[HOST_PLAYMODE]模式");
break;
case 1:
2026-01-05 17:58:53 +08:00
ChangePlayerSchema.SetPlayerMode(PLayerMode.HOST_PLAYMODE);
Debug.Log("切换为[HOST_PLAYMODE]模式");
2025-07-14 18:26:17 +08:00
break;
case 2:
break;
}
}
2025-04-14 12:18:19 +08:00
}
public void OnPostprocessBuild(UnityEditor.Build.Reporting.BuildReport report)
{
// build完成后
}
}
}