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)
|
|
|
|
|
|
{
|
2025-07-14 18:32:27 +08:00
|
|
|
|
string platform = EditorPrefs.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}]模式,请选择切换得热更模式!",
|
|
|
|
|
|
$"{PLayerMode.HOST_PLAYMODE}", $"{PLayerMode.OFFLINE_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:
|
|
|
|
|
|
ChangePlayerSchema.SetPlayerMode(PLayerMode.OFFLINE_PLAYMODE);
|
|
|
|
|
|
Debug.Log("切换为[OFFLINE_PLAYMODE]模式");
|
|
|
|
|
|
break;
|
|
|
|
|
|
case 2:
|
|
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-04-14 12:18:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void OnPostprocessBuild(UnityEditor.Build.Reporting.BuildReport report)
|
|
|
|
|
|
{
|
|
|
|
|
|
// build完成后
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|