modular-avatar/Editor/ParamsUsage/ParamsUsagePrefs.cs
bd_ 926ea255cb
feat: add menu option to disable "modular avatar information" display (#833)
* feat: add menu option to disable "modular avatar information" display

Closes: #815
2024-04-22 09:00:37 +09:00

40 lines
1.5 KiB
C#

using System;
using nadena.dev.modular_avatar.ui;
using UnityEditor;
using UnityEngine.Serialization;
namespace nadena.dev.modular_avatar.core.editor
{
#if UNITY_2022_3_OR_NEWER
[FilePath("modular-avatar/ParamsUsagePrefs.asset", FilePathAttribute.Location.PreferencesFolder)]
internal sealed class ParamsUsagePrefs : ScriptableSingleton<ParamsUsagePrefs>
{
public static event Action<bool> OnChange_EnableInfoMenu;
[FormerlySerializedAs("EnableInfoMenu")] public bool enableInfoMenu = true;
[MenuItem(UnityMenuItems.TopMenu_EnableInfo, false, UnityMenuItems.TopMenu_EnableInfoOrder)]
private static void Menu_EnableInfo()
{
ParamsUsagePrefs.instance.enableInfoMenu = !ParamsUsagePrefs.instance.enableInfoMenu;
Menu.SetChecked(UnityMenuItems.TopMenu_EnableInfo, ParamsUsagePrefs.instance.enableInfoMenu);
ParamsUsagePrefs.instance.Save(true);
OnChange_EnableInfoMenu?.Invoke(ParamsUsagePrefs.instance.enableInfoMenu);
}
[InitializeOnLoadMethod]
private static void Initialize()
{
Menu.SetChecked(UnityMenuItems.TopMenu_EnableInfo, ParamsUsagePrefs.instance.enableInfoMenu);
}
}
#else
internal sealed class ParamsUsagePrefs
{
public static ParamsUsagePrefs instance => new ParamsUsagePrefs();
public static event Action<bool> OnChange_EnableInfoMenu;
public bool enableInfoMenu => false;
}
#endif
}