From 6bc6ab7143fe08119df0dc16372b497435d3f982 Mon Sep 17 00:00:00 2001 From: XtraCube <72575280+XtraCube@users.noreply.github.com> Date: Tue, 27 Aug 2024 19:22:48 -0400 Subject: [PATCH] fix button issue --- MiraAPI/Hud/CustomActionButton.cs | 3 ++- MiraAPI/Patches/PlayerControlPatches.cs | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/MiraAPI/Hud/CustomActionButton.cs b/MiraAPI/Hud/CustomActionButton.cs index 04102b3..16e72a4 100644 --- a/MiraAPI/Hud/CustomActionButton.cs +++ b/MiraAPI/Hud/CustomActionButton.cs @@ -3,6 +3,7 @@ using MiraAPI.Utilities.Assets; using UnityEngine; using UnityEngine.Events; +using UnityEngine.UI; namespace MiraAPI.Hud; @@ -95,7 +96,7 @@ internal void CreateButton(Transform parent) } var pb = Button.GetComponent(); - pb.OnClick.RemoveAllListeners(); + pb.OnClick = new Button.ButtonClickedEvent(); pb.OnClick.AddListener((UnityAction)ClickHandler); } diff --git a/MiraAPI/Patches/PlayerControlPatches.cs b/MiraAPI/Patches/PlayerControlPatches.cs index 97a7e84..f4f79ce 100644 --- a/MiraAPI/Patches/PlayerControlPatches.cs +++ b/MiraAPI/Patches/PlayerControlPatches.cs @@ -37,9 +37,9 @@ public static void PlayerControlFixedUpdatePostfix(PlayerControl __instance) foreach (var button in CustomButtonManager.CustomButtons) { - if (__instance.Data?.Role != null) + if (__instance.Data?.Role == null) { - return; + continue; } if (!button.Enabled(__instance.Data?.Role))