2024-02-18 19:21:26 +08:00
|
|
|
|
#region
|
|
|
|
|
|
2024-02-26 17:56:43 +08:00
|
|
|
|
using System;
|
2024-02-18 19:21:26 +08:00
|
|
|
|
using HarmonyLib;
|
|
|
|
|
using UnityEditor;
|
2024-02-26 17:56:43 +08:00
|
|
|
|
using UnityEngine;
|
2024-02-18 19:21:26 +08:00
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
namespace nadena.dev.modular_avatar.core.editor.HarmonyPatches
|
|
|
|
|
{
|
|
|
|
|
internal class PatchLoader
|
|
|
|
|
{
|
2024-02-26 17:56:43 +08:00
|
|
|
|
private static readonly Action<Harmony>[] patches = new Action<Harmony>[]
|
|
|
|
|
{
|
2024-03-03 16:26:23 +08:00
|
|
|
|
HierarchyViewPatches.Patch,
|
|
|
|
|
#if UNITY_2022_3_OR_NEWER
|
|
|
|
|
HandleUtilityPatches.Patch_FilterInstanceIDs,
|
|
|
|
|
PickingObjectPatch.Patch,
|
|
|
|
|
#endif
|
2024-02-26 17:56:43 +08:00
|
|
|
|
};
|
|
|
|
|
|
2024-02-18 19:21:26 +08:00
|
|
|
|
[InitializeOnLoadMethod]
|
|
|
|
|
static void ApplyPatches()
|
|
|
|
|
{
|
|
|
|
|
var harmony = new Harmony("nadena.dev.modular_avatar");
|
|
|
|
|
|
2024-02-26 17:56:43 +08:00
|
|
|
|
foreach (var patch in patches)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
patch(harmony);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
Debug.LogException(e);
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-03-14 20:33:44 +08:00
|
|
|
|
|
|
|
|
|
AssemblyReloadEvents.beforeAssemblyReload += () => { harmony.UnpatchAll(); };
|
2024-02-18 19:21:26 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|