Files
CC-Framework.EditorExtend/Assets/CCTools/Editor/Config/CCToolsConfig.cs
2025-02-11 17:05:39 +08:00

89 lines
1.4 KiB
C#

using UnityEngine;
using UnityEditor;
namespace CCTools.Config
{
public static class CCToolsConfig
{
private const string ENABLE_FIGMA_UPDATE_KEY = "CCTools.EnableFigmaUpdate";
private const string MENU_ITEM_PATH = "CC-Tools/RectTransform Tool/Enable Figma Update";
// 默认启用
public static bool enableFigmaUpdate = true;
static CCToolsConfig()
{
// 从 EditorPrefs 加载保存的状态
enableFigmaUpdate = EditorPrefs.GetBool(ENABLE_FIGMA_UPDATE_KEY, true);
}
public static bool EnableFigmaUpdate
{
get => enableFigmaUpdate;
private set
{
if (enableFigmaUpdate != value)
{
enableFigmaUpdate = value;
EditorPrefs.SetBool(ENABLE_FIGMA_UPDATE_KEY, value);
// 刷新编辑器
UnityEditorInternal.InternalEditorUtility.RepaintAllViews();
}
}
}
[MenuItem(MENU_ITEM_PATH)]
private static void ToggleFigmaUpdate()
{
enableFigmaUpdate = !enableFigmaUpdate;
}
[MenuItem(MENU_ITEM_PATH, true)]
private static bool ToggleFigmaUpdateValidate()
{
Menu.SetChecked(MENU_ITEM_PATH, enableFigmaUpdate);
return true;
}
}
}