using UnityEngine;
using System.Collections;
using MoreMountains.Tools;
using UnityEditor;
namespace MoreMountains.Tools
{
///
/// This class adds a MoreMountains entry in Unity's top menu, allowing to enable/disable the help texts from the engine's inspectors
///
public static class MMMenuHelp
{
[MenuItem("Tools/More Mountains/Enable Help in Inspectors", false,0)]
///
/// Adds a menu item to enable help
///
private static void EnableHelpInInspectors()
{
SetHelpEnabled(true);
}
[MenuItem("Tools/More Mountains/Enable Help in Inspectors", true)]
///
/// Conditional method to determine if the "enable help" entry should be greyed or not
///
private static bool EnableHelpInInspectorsValidation()
{
return !HelpEnabled();
}
[MenuItem("Tools/More Mountains/Disable Help in Inspectors", false,1)]
///
/// Adds a menu item to disable help
///
private static void DisableHelpInInspectors()
{
SetHelpEnabled(false);
}
[MenuItem("Tools/More Mountains/Disable Help in Inspectors", true)]
///
/// Conditional method to determine if the "disable help" entry should be greyed or not
///
private static bool DisableHelpInInspectorsValidation()
{
return HelpEnabled();
}
///
/// Checks editor prefs to see if help is enabled or not
///
/// true, if enabled was helped, false otherwise.
private static bool HelpEnabled()
{
if (EditorPrefs.HasKey("MMShowHelpInInspectors"))
{
return EditorPrefs.GetBool("MMShowHelpInInspectors");
}
else
{
EditorPrefs.SetBool("MMShowHelpInInspectors",true);
return true;
}
}
///
/// Sets the help enabled editor pref.
///
/// If set to true status.
private static void SetHelpEnabled(bool status)
{
EditorPrefs.SetBool("MMShowHelpInInspectors",status);
SceneView.RepaintAll();
}
}
}