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.
37 lines
1.0 KiB
C#
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;
|
||
|
}
|
||
|
}
|
||
|
}
|