50 lines
1.7 KiB
C#
50 lines
1.7 KiB
C#
using UnityEditor;
|
|
|
|
/// <summary>
|
|
/// 新手引导开关
|
|
/// </summary>
|
|
public class GuideEditor : Editor
|
|
{
|
|
/// <summary>
|
|
/// 新手引导宏
|
|
/// </summary>
|
|
private const string MACRO_GUIDE = "GUIDE";
|
|
private const string GUIDE_TOOL = "Tools/新手引导";
|
|
|
|
[MenuItem(GUIDE_TOOL, true)]
|
|
public static bool GuideMenu()
|
|
{
|
|
BuildTargetGroup currentTargetGroup = BuildPipeline.GetBuildTargetGroup(EditorUserBuildSettings.activeBuildTarget);
|
|
string currentDefines = PlayerSettings.GetScriptingDefineSymbolsForGroup(currentTargetGroup);
|
|
|
|
Menu.SetChecked(GUIDE_TOOL, currentDefines.Contains(MACRO_GUIDE));
|
|
|
|
return true;
|
|
}
|
|
|
|
[MenuItem(GUIDE_TOOL)]
|
|
public static void SwitchGuide()
|
|
{
|
|
BuildTargetGroup currentTargetGroup = BuildPipeline.GetBuildTargetGroup(EditorUserBuildSettings.activeBuildTarget);
|
|
string currentDefines = PlayerSettings.GetScriptingDefineSymbolsForGroup(currentTargetGroup);
|
|
bool isCheck = !currentDefines.Contains(MACRO_GUIDE);
|
|
|
|
SetDefineSymbols(currentTargetGroup, MACRO_GUIDE, isCheck);
|
|
|
|
Menu.SetChecked(GUIDE_TOOL, isCheck);
|
|
}
|
|
|
|
private static void SetDefineSymbols(BuildTargetGroup buildTargetGroup, string define, bool enable)
|
|
{
|
|
string currentDefines = PlayerSettings.GetScriptingDefineSymbolsForGroup(buildTargetGroup);//获取目标平台下的宏命令
|
|
if (enable)
|
|
{
|
|
if (!currentDefines.Contains(define))
|
|
currentDefines += $";{define}";
|
|
}
|
|
else
|
|
currentDefines = currentDefines.Replace(define, string.Empty);
|
|
|
|
PlayerSettings.SetScriptingDefineSymbolsForGroup(buildTargetGroup, currentDefines);
|
|
}
|
|
} |