From 35b32fb5ec2c2161006b67b25f1bd179b7906832 Mon Sep 17 00:00:00 2001 From: flibber-hk <76987839+flibber-hk@users.noreply.github.com> Date: Mon, 6 Apr 2026 07:36:13 +0100 Subject: [PATCH 1/2] Support multiple animators --- Silksong.ModMenu/Elements/TextInput.cs | 8 +++++-- ...per.cs => MenuSelectableAnimationProxy.cs} | 23 ++++++++++++------- 2 files changed, 21 insertions(+), 10 deletions(-) rename Silksong.ModMenu/Internal/{DescriptionAnimationHelper.cs => MenuSelectableAnimationProxy.cs} (75%) diff --git a/Silksong.ModMenu/Elements/TextInput.cs b/Silksong.ModMenu/Elements/TextInput.cs index dcc2b91..50d6abf 100644 --- a/Silksong.ModMenu/Elements/TextInput.cs +++ b/Silksong.ModMenu/Elements/TextInput.cs @@ -49,8 +49,12 @@ public TextInput(LocalizedText label, ITextModel model, LocalizedText descrip else if (floatTypes.Contains(typeof(T))) InputField.contentType = InputField.ContentType.DecimalNumber; - input.AddComponent().DescriptionAnimator = - DescriptionText.gameObject.GetComponent(); + input.AddComponent().Animators = + [ + input.FindChild("Description")!.GetComponent(), + input.FindChild("CursorLeft")!.GetComponent(), + input.FindChild("CursorRight")!.GetComponent(), + ]; } /// diff --git a/Silksong.ModMenu/Internal/DescriptionAnimationHelper.cs b/Silksong.ModMenu/Internal/MenuSelectableAnimationProxy.cs similarity index 75% rename from Silksong.ModMenu/Internal/DescriptionAnimationHelper.cs rename to Silksong.ModMenu/Internal/MenuSelectableAnimationProxy.cs index 5abf588..c03cb24 100644 --- a/Silksong.ModMenu/Internal/DescriptionAnimationHelper.cs +++ b/Silksong.ModMenu/Internal/MenuSelectableAnimationProxy.cs @@ -1,18 +1,19 @@ using System.Collections; +using System.Collections.Generic; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.UI; namespace Silksong.ModMenu.Internal; -internal class DescriptionAnimationHelper +internal class MenuSelectableAnimationProxy : MonoBehaviour, ISelectHandler, IDeselectHandler, ICancelHandler { private Selectable _selectable; - public Animator? DescriptionAnimator { get; set; } + public List Animators = []; void Awake() { @@ -27,7 +28,7 @@ public void OnDeselect(BaseEventData eventData) // My best attempt to imitate the code from MenuSelectable.ValidateDeselect private IEnumerator ValidateDeselect(BaseEventData eventData, bool force) { - if (DescriptionAnimator == null) + if (Animators.Count == 0) { yield break; } @@ -51,8 +52,11 @@ private IEnumerator ValidateDeselect(BaseEventData eventData, bool force) if (EventSystem.current.currentSelectedGameObject != null || force) { - DescriptionAnimator.ResetTrigger(MenuSelectable._showPropId); - DescriptionAnimator.SetTrigger(MenuSelectable._hidePropId); + foreach (Animator animator in Animators) + { + animator.ResetTrigger(MenuSelectable._showPropId); + animator.SetTrigger(MenuSelectable._hidePropId); + } } else if (prevSelectedObject != null && prevSelectedObject.activeInHierarchy) { @@ -62,7 +66,7 @@ private IEnumerator ValidateDeselect(BaseEventData eventData, bool force) public void OnSelect(BaseEventData eventData) { - if (DescriptionAnimator == null) + if (Animators.Count == 0) { return; } @@ -72,8 +76,11 @@ public void OnSelect(BaseEventData eventData) return; } - DescriptionAnimator.ResetTrigger(MenuSelectable._hidePropId); - DescriptionAnimator.SetTrigger(MenuSelectable._showPropId); + foreach (Animator animator in Animators) + { + animator.ResetTrigger(MenuSelectable._hidePropId); + animator.SetTrigger(MenuSelectable._showPropId); + } } public void OnCancel(BaseEventData eventData) From c5e98ae0c4ea8057b68b8b3a96eeeef63cecfee2 Mon Sep 17 00:00:00 2001 From: flibber-hk <76987839+flibber-hk@users.noreply.github.com> Date: Mon, 6 Apr 2026 07:40:01 +0100 Subject: [PATCH 2/2] Add the ap component to the prefab --- Silksong.ModMenu/Elements/TextInput.cs | 7 ------- Silksong.ModMenu/Internal/MenuPrefabs.cs | 6 ++++++ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/Silksong.ModMenu/Elements/TextInput.cs b/Silksong.ModMenu/Elements/TextInput.cs index 50d6abf..91dede6 100644 --- a/Silksong.ModMenu/Elements/TextInput.cs +++ b/Silksong.ModMenu/Elements/TextInput.cs @@ -48,13 +48,6 @@ public TextInput(LocalizedText label, ITextModel model, LocalizedText descrip InputField.contentType = InputField.ContentType.IntegerNumber; else if (floatTypes.Contains(typeof(T))) InputField.contentType = InputField.ContentType.DecimalNumber; - - input.AddComponent().Animators = - [ - input.FindChild("Description")!.GetComponent(), - input.FindChild("CursorLeft")!.GetComponent(), - input.FindChild("CursorRight")!.GetComponent(), - ]; } /// diff --git a/Silksong.ModMenu/Internal/MenuPrefabs.cs b/Silksong.ModMenu/Internal/MenuPrefabs.cs index d972177..b43404c 100644 --- a/Silksong.ModMenu/Internal/MenuPrefabs.cs +++ b/Silksong.ModMenu/Internal/MenuPrefabs.cs @@ -127,6 +127,12 @@ private MenuPrefabs(UIManager uiManager) textInputField.contentType = InputField.ContentType.Standard; textInputField.caretWidth = 8; textInputField.text = ""; + textInputChild.AddComponent().Animators = + [ + textInputChild.FindChild("Description")!.GetComponent(), + textInputChild.FindChild("CursorLeft")!.GetComponent(), + textInputChild.FindChild("CursorRight")!.GetComponent(), + ]; sliderTemplate = Object.Instantiate( canvas.FindChild("AudioMenuScreen/Content/MasterVolume")!