99 lines
3.3 KiB
C#
99 lines
3.3 KiB
C#
using Gameplay.FirstTimeFlow;
|
|
using Gameplay.FunctionLock;
|
|
using Gameplay.Guide;
|
|
using UnityEditor;
|
|
using UnityEngine;
|
|
|
|
/// <summary>
|
|
/// 功能开关窗口
|
|
/// </summary>
|
|
public sealed class FunctionSwitchWindow : EditorWindow
|
|
{
|
|
[MenuItem("Tools/*功能开关")]
|
|
private static void ShowWindow()
|
|
{
|
|
FunctionSwitchWindow window = (FunctionSwitchWindow)GetWindow(typeof(FunctionSwitchWindow), true, "功能开关");
|
|
window.Show();
|
|
window.Focus();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 是否开启强制流程
|
|
/// </summary>
|
|
private static bool isEnableFirstTimeFlowStatic;
|
|
/// <summary>
|
|
/// 是否开启引导
|
|
/// </summary>
|
|
private static bool isEnableGuideStatic;
|
|
/// <summary>
|
|
/// 是否开启功能锁
|
|
/// </summary>
|
|
private static bool isEnableFunctionLockStatic;
|
|
|
|
/// <summary>
|
|
/// 是否开启强制流程
|
|
/// </summary>
|
|
private bool isEnableFirstTimeFlow;
|
|
/// <summary>
|
|
/// 是否开启引导
|
|
/// </summary>
|
|
private bool isEnableGuide;
|
|
/// <summary>
|
|
/// 是否开启功能锁
|
|
/// </summary>
|
|
private bool isEnableFunctionLock;
|
|
|
|
private void OnEnable()
|
|
{
|
|
isEnableFirstTimeFlow = isEnableFirstTimeFlowStatic || 1 == PlayerPrefs.GetInt(FirstTimeFlowManager.SWITCH_KEY, 0);
|
|
isEnableGuide = isEnableGuideStatic || 1 == PlayerPrefs.GetInt(GuideManager.SWITCH_KEY, 0);
|
|
isEnableFunctionLock = isEnableFunctionLockStatic || 1 == PlayerPrefs.GetInt(FunctionLockManager.SWITCH_KEY, 0);
|
|
}
|
|
|
|
private void OnGUI()
|
|
{
|
|
isEnableFirstTimeFlow = EditorGUILayout.Toggle("强制流程", isEnableFirstTimeFlow);
|
|
isEnableGuide = EditorGUILayout.Toggle("新手引导(开引导默认开强制流程)", isEnableGuide);
|
|
if (isEnableGuide)
|
|
isEnableFirstTimeFlow = true;
|
|
|
|
isEnableFunctionLock = EditorGUILayout.Toggle("功能锁", isEnableFunctionLock);
|
|
|
|
if (GUILayout.Button("确定"))
|
|
{
|
|
isEnableFirstTimeFlowStatic = isEnableFirstTimeFlow;
|
|
isEnableGuideStatic = isEnableGuide;
|
|
isEnableFunctionLockStatic = isEnableFunctionLock;
|
|
SetSwitchState(FirstTimeFlowManager.SWITCH_KEY, isEnableFirstTimeFlow);
|
|
SetSwitchState(GuideManager.SWITCH_KEY, isEnableGuide);
|
|
SetSwitchState(FunctionLockManager.SWITCH_KEY, isEnableFunctionLock);
|
|
PlayerPrefs.Save();
|
|
Close();
|
|
}
|
|
}
|
|
|
|
private void SetSwitchState(string key, bool isOpen)
|
|
{
|
|
PlayerPrefs.SetInt(key, isOpen ? 1 : 0);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 设置宏定义列表
|
|
/// </summary>
|
|
/// <param name="buildTargetGroup"></param>
|
|
/// <param name="define"></param>
|
|
/// <param name="enable"></param>
|
|
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);
|
|
}
|
|
} |