diff --git a/Directory.Build.props b/Directory.Build.props
index d7583c7..171b240 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -11,6 +11,6 @@
It should follow the format major.minor.patch (semantic versioning). If you publish your mod
as a library to NuGet, this version will also be used as the package version.
-->
- 0.4.1
+ 0.4.2
diff --git a/Elements/LocalizedTextExtensions.cs b/Elements/LocalizedTextExtensions.cs
index 59974f6..f5e991e 100644
--- a/Elements/LocalizedTextExtensions.cs
+++ b/Elements/LocalizedTextExtensions.cs
@@ -1,4 +1,5 @@
-using UnityEngine.UI;
+using Silksong.ModMenu.Internal;
+using UnityEngine.UI;
namespace Silksong.ModMenu.Elements;
@@ -27,8 +28,11 @@ public LocalizedText LocalizedText
{
if (!self.TryGetComponent(out var auto))
{
- auto = self.gameObject.AddComponent();
- auto.textField = self;
+ using (self.gameObject.TempInactive())
+ {
+ auto = self.gameObject.AddComponent();
+ auto.textField = self;
+ }
}
auto.text = value.Localized;
diff --git a/Internal/CustomMappableKey.cs b/Internal/CustomMappableKey.cs
index f81f891..c32af58 100644
--- a/Internal/CustomMappableKey.cs
+++ b/Internal/CustomMappableKey.cs
@@ -49,25 +49,26 @@ internal static CustomMappableKey Replace(MappableKey src)
var obj = src.gameObject;
DestroyImmediate(src); // We cannot wait 1 frame to add a new Selectable component.
- var wasActive = obj.activeSelf;
- obj.SetActive(false);
- CustomMappableKey dest = obj.AddComponent();
- dest.animationTriggers = animationTriggers;
- dest.buttonType = MenuButtonType.Proceed;
- dest.cancelAction = CancelAction.DoNothing;
- dest.colors = colors;
- dest.DontPlaySelectSound = true;
- dest.KeymapImage = keymapImage;
- dest.KeymapText = keymapText;
- dest.leftCursor = leftCursor;
- dest.menuCancelVibration = menuCancelVibration;
- dest.menuSubmitVibration = menuSubmitVibration;
- dest.playSubmitSound = true;
- dest.prevSelectedObject = obj;
- dest.rightCursor = rightCursor;
- dest.transition = Transition.None;
- dest.uiAudioPlayer = UIManager.instance.uiAudioPlayer;
- obj.SetActive(wasActive);
+ CustomMappableKey dest;
+ using (obj.TempInactive())
+ {
+ dest = obj.AddComponent();
+ dest.animationTriggers = animationTriggers;
+ dest.buttonType = MenuButtonType.Proceed;
+ dest.cancelAction = CancelAction.DoNothing;
+ dest.colors = colors;
+ dest.DontPlaySelectSound = true;
+ dest.KeymapImage = keymapImage;
+ dest.KeymapText = keymapText;
+ dest.leftCursor = leftCursor;
+ dest.menuCancelVibration = menuCancelVibration;
+ dest.menuSubmitVibration = menuSubmitVibration;
+ dest.playSubmitSound = true;
+ dest.prevSelectedObject = obj;
+ dest.rightCursor = rightCursor;
+ dest.transition = Transition.None;
+ dest.uiAudioPlayer = UIManager.instance.uiAudioPlayer;
+ }
return dest;
}
diff --git a/Internal/EnumUtil.cs b/Internal/EnumUtil.cs
index b5bfae2..13dd665 100644
--- a/Internal/EnumUtil.cs
+++ b/Internal/EnumUtil.cs
@@ -50,7 +50,7 @@ internal static ReadOnlyDictionary