You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
CrowdControl/Assets/3rd/Plugins/Smart-Inspector/Patches/EditorHeaderItemPatch.cs

37 lines
1.0 KiB
C#

2 months ago
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
namespace AV.Inspector
{
internal class EditorHeaderItemPatch : PatchBase
{
static InspectorPrefs prefs = InspectorPrefs.Loaded;
protected override IEnumerable<Patch> GetPatches()
{
var attributeType = EditorAssembly.GetType("UnityEditor.EditorHeaderItemAttribute");
foreach (var method in TypeCache.GetMethodsWithAttribute(attributeType))
{
var name = method.Name;
if (name == "HelpIconButton")
yield return new Patch(method, nameof(_HelpIconButton), apply: Apply.OnGUI);
if (name == "DrawPresetButton")
yield return new Patch(method, nameof(_DrawPresetButton), apply: Apply.OnGUI);
}
}
static bool _HelpIconButton()
{
return prefs.showHelp;
}
static bool _DrawPresetButton()
{
return prefs.showPreset;
}
}
}