From 88473b94be3ba716352939ed3a1340d853d8e834 Mon Sep 17 00:00:00 2001 From: lxymahatma <326265648@qq.com> Date: Sun, 12 Feb 2023 21:28:49 +0900 Subject: [PATCH] add two more overloads for pnlmenu toggle create, fix toggle group --- src/MelonBuildInfo.cs | 2 +- src/UICreate/ToggleCreate.cs | 40 ++++++++++++++++++++++++++++-------- 2 files changed, 32 insertions(+), 10 deletions(-) diff --git a/src/MelonBuildInfo.cs b/src/MelonBuildInfo.cs index f6f0fe2..afa9f7a 100644 --- a/src/MelonBuildInfo.cs +++ b/src/MelonBuildInfo.cs @@ -8,6 +8,6 @@ internal static class MelonBuildInfo public const string Author = "lxy"; - public const string Version = "1.1.0"; + public const string Version = "1.1.1"; } } \ No newline at end of file diff --git a/src/UICreate/ToggleCreate.cs b/src/UICreate/ToggleCreate.cs index 6891787..569301a 100644 --- a/src/UICreate/ToggleCreate.cs +++ b/src/UICreate/ToggleCreate.cs @@ -57,7 +57,7 @@ public static unsafe GameObject CreateToggle(string name, Vector3 position, bool public static unsafe GameObject CreateToggle(string name, Vector3 position, bool* isEnabled, string text, string parentName, ToggleGroup toggleGroup) { var toggle = CreateToggle(name, position, isEnabled, text, parentName); - toggleGroup.RegisterToggle(toggle.GetComponent()); + toggle.GetComponent().group = toggleGroup; return toggle; } @@ -79,7 +79,7 @@ public static unsafe GameObject CreateToggle(string name, Vector3 position, bool public static unsafe GameObject CreateToggle(string name, Vector3 position, bool* isEnabled, string text, string parentName, int fontSize, Color textColor, ToggleGroup toggleGroup) { var toggle = CreateToggle(name, position, isEnabled, text, parentName, fontSize, textColor); - toggleGroup.RegisterToggle(toggle.GetComponent()); + toggle.GetComponent().group = toggleGroup; return toggle; } @@ -102,7 +102,7 @@ public static unsafe GameObject CreateToggle(string name, Vector3 position, bool public static unsafe GameObject CreateToggle(string name, Vector3 position, bool* isEnabled, string text, string parentName, int fontSize, Color textColor, Color checkBoxColor, Color checkMarkColor, ToggleGroup toggleGroup) { var toggle = CreateToggle(name, position, isEnabled, text, parentName, fontSize, textColor, checkBoxColor, checkMarkColor); - toggleGroup.RegisterToggle(toggle.GetComponent()); + toggle.GetComponent().group = toggleGroup; return toggle; } @@ -149,7 +149,7 @@ public static unsafe GameObject CreateToggle(string name, Vector3 position, bool public static unsafe GameObject CreateToggle(string name, Vector3 position, bool* isEnabled, string text, GameObject parent, ToggleGroup toggleGroup) { var toggle = CreateToggle(name, position, isEnabled, text, parent); - toggleGroup.RegisterToggle(toggle.GetComponent()); + toggle.GetComponent().group = toggleGroup; return toggle; } @@ -171,7 +171,7 @@ public static unsafe GameObject CreateToggle(string name, Vector3 position, bool public static unsafe GameObject CreateToggle(string name, Vector3 position, bool* isEnabled, string text, GameObject parent, int fontSize, Color textColor, ToggleGroup toggleGroup) { var toggle = CreateToggle(name, position, isEnabled, text, parent, fontSize, textColor); - toggleGroup.RegisterToggle(toggle.GetComponent()); + toggle.GetComponent().group = toggleGroup; return toggle; } @@ -194,7 +194,7 @@ public static unsafe GameObject CreateToggle(string name, Vector3 position, bool public static unsafe GameObject CreateToggle(string name, Vector3 position, bool* isEnabled, string text, GameObject parent, int fontSize, Color textColor, Color checkBoxColor, Color checkMarkColor, ToggleGroup toggleGroup) { var toggle = CreateToggle(name, position, isEnabled, text, parent, fontSize, textColor, checkBoxColor, checkMarkColor); - toggleGroup.RegisterToggle(toggle.GetComponent()); + toggle.GetComponent().group = toggleGroup; return toggle; } @@ -241,7 +241,7 @@ public static unsafe GameObject CreateToggle(string name, Vector3 position, bool public static unsafe GameObject CreateToggle(string name, Vector3 position, bool* isEnabled, string text, Transform parent, ToggleGroup toggleGroup) { var toggle = CreateToggle(name, position, isEnabled, text, parent); - toggleGroup.RegisterToggle(toggle.GetComponent()); + toggle.GetComponent().group = toggleGroup; return toggle; } @@ -263,7 +263,7 @@ public static unsafe GameObject CreateToggle(string name, Vector3 position, bool public static unsafe GameObject CreateToggle(string name, Vector3 position, bool* isEnabled, string text, Transform parent, int fontSize, Color textColor, ToggleGroup toggleGroup) { var toggle = CreateToggle(name, position, isEnabled, text, parent, fontSize, textColor); - toggleGroup.RegisterToggle(toggle.GetComponent()); + toggle.GetComponent().group = toggleGroup; return toggle; } @@ -286,7 +286,7 @@ public static unsafe GameObject CreateToggle(string name, Vector3 position, bool public static unsafe GameObject CreateToggle(string name, Vector3 position, bool* isEnabled, string text, Transform parent, int fontSize, Color textColor, Color checkBoxColor, Color checkMarkColor, ToggleGroup toggleGroup) { var toggle = CreateToggle(name, position, isEnabled, text, parent, fontSize, textColor, checkBoxColor, checkMarkColor); - toggleGroup.RegisterToggle(toggle.GetComponent()); + toggle.GetComponent().group = toggleGroup; return toggle; } @@ -334,6 +334,28 @@ public static unsafe GameObject CreatePnlMenuToggle(string name, bool* isEnabled return toggle; } + /// + /// Create Toggle at PnlMenu with toggle group + /// + public static unsafe GameObject CreatePnlMenuToggle(string name, bool* isEnabled, string text, string parentName, ToggleGroup toggleGroup) + { + var toggle = CreatePnlMenuToggle(name, isEnabled, text); + toggle.transform.SetParent(GameObject.Find(parentName).transform); + toggle.GetComponent().group = toggleGroup; + return toggle; + } + + /// + /// Create Toggle at PnlMenu with toggle group + /// + public static unsafe GameObject CreatePnlMenuToggle(string name, bool* isEnabled, string text, GameObject parent, ToggleGroup toggleGroup) + { + var toggle = CreatePnlMenuToggle(name, isEnabled, text); + toggle.transform.SetParent(parent.transform); + toggle.GetComponent().group = toggleGroup; + return toggle; + } + /// /// Create Toggle at PnlMenu with custom fontsize and text color ///