From 82258cfa7e6804e876374066475117b44fc90e7c Mon Sep 17 00:00:00 2001 From: _nebula <41904486+misternebula@users.noreply.github.com> Date: Tue, 19 Mar 2024 16:06:31 +0000 Subject: [PATCH] edit localposition and fix label rotation --- .../NewMenuSystem/OptionsMenuManager.cs | 14 ++++++++++++++ .../NewMenuSystem/TitleMenuManager.cs | 1 + 2 files changed, 15 insertions(+) diff --git a/src/OWML.ModHelper.Menus/NewMenuSystem/OptionsMenuManager.cs b/src/OWML.ModHelper.Menus/NewMenuSystem/OptionsMenuManager.cs index 406e0c17..7fc6a4e8 100644 --- a/src/OWML.ModHelper.Menus/NewMenuSystem/OptionsMenuManager.cs +++ b/src/OWML.ModHelper.Menus/NewMenuSystem/OptionsMenuManager.cs @@ -29,6 +29,7 @@ public OptionsMenuManager(IModConsole console, IModUnityEvents unityEvents, IPop var newMenu = Object.Instantiate(existingMenu); newMenu.transform.parent = existingMenu.transform.parent; newMenu.transform.localScale = Vector3.one; + newMenu.transform.localPosition = Vector3.zero; newMenu.transform.localRotation = Quaternion.identity; var rt = newMenu.GetComponent(); var ert = existingMenu.GetComponent(); @@ -81,6 +82,7 @@ public OptionsMenuManager(IModConsole console, IModUnityEvents unityEvents, IPop var newSubMenu = Object.Instantiate(existingTabbedSubMenu); newSubMenu.transform.parent = existingTabbedSubMenu.transform.parent; newSubMenu.transform.localScale = Vector3.one; + newSubMenu.transform.localPosition = Vector3.zero; newSubMenu.transform.localRotation = Quaternion.identity; var rectTransform = newSubMenu.GetComponent(); rectTransform.anchorMin = existingTabbedSubMenu.GetComponent().anchorMin; @@ -165,6 +167,7 @@ public void RemoveTab(Menu tab) var newSubMenuTabButton = Object.Instantiate(existingSubMenuTabButton); newSubMenuTabButton.transform.parent = menu.transform.Find("SubMenuTabs"); newSubMenuTabButton.transform.localScale = Vector3.one; + newSubMenuTabButton.transform.localPosition = Vector3.zero; newSubMenuTabButton.transform.localRotation = Quaternion.identity; newSubMenuTabButton.transform.SetSiblingIndex(newSubMenuTabButton.transform.parent.childCount - 2); newSubMenuTabButton.name = $"Button-{name}Tab"; @@ -174,6 +177,7 @@ public void RemoveTab(Menu tab) var newSubMenu = Object.Instantiate(existingSubMenu); newSubMenu.transform.parent = menu.transform; newSubMenu.transform.localScale = Vector3.one; + newSubMenu.transform.localPosition = Vector3.zero; newSubMenu.name = $"Menu{name}"; newSubMenu.transform.localRotation = Quaternion.identity; @@ -232,6 +236,7 @@ public IOWMLToggleElement AddCheckboxInput(Menu menu, string label, string toolt var newCheckbox = Object.Instantiate(existingCheckbox); newCheckbox.transform.parent = GetParentForAddedElements(menu); + newCheckbox.transform.localPosition = Vector3.zero; newCheckbox.transform.localScale = Vector3.one; newCheckbox.transform.name = $"UIElement-{label}"; newCheckbox.transform.localRotation = Quaternion.identity; @@ -280,6 +285,7 @@ public IOWMLTwoButtonToggleElement AddToggleInput(Menu menu, string label, strin var newToggle = Object.Instantiate(prefab); newToggle.transform.parent = GetParentForAddedElements(menu); + newToggle.transform.localPosition = Vector3.zero; newToggle.transform.localScale = Vector3.one; newToggle.transform.name = $"UIElement-{label}"; newToggle.transform.localRotation = Quaternion.identity; @@ -328,6 +334,7 @@ public IOWMLOptionsSelectorElement AddSelectorInput(Menu menu, string label, str .Find("UIElement-ControllerProfile").gameObject; var newSelector = Object.Instantiate(existingSelector); + newSelector.transform.localPosition = Vector3.zero; newSelector.transform.parent = GetParentForAddedElements(menu); newSelector.transform.localScale = Vector3.one; newSelector.transform.name = $"UIElement-{label}"; @@ -377,6 +384,7 @@ public IOWMLSliderElement AddSliderInput(Menu menu, string label, float lower, f var newSlider = Object.Instantiate(existingSlider); newSlider.transform.parent = GetParentForAddedElements(menu); + newSlider.transform.localPosition = Vector3.zero; newSlider.transform.localScale = Vector3.one; newSlider.transform.name = $"UIElement-{label}"; newSlider.transform.localRotation = Quaternion.identity; @@ -467,6 +475,7 @@ public SubmitAction CreateButton(Menu menu, string buttonLabel, string tooltip, var newButtonObj = Object.Instantiate(existingButton); newButtonObj.transform.parent = GetParentForAddedElements(menu); + newButtonObj.transform.localPosition = Vector3.zero; newButtonObj.transform.localScale = Vector3.one; newButtonObj.name = $"UIElement-Button-{buttonLabel}"; newButtonObj.transform.localRotation = Quaternion.identity; @@ -525,6 +534,7 @@ public SubmitAction CreateButtonWithLabel(Menu menu, string label, string button var newHorizLayout = Object.Instantiate(existingHorizLayout); newHorizLayout.transform.parent = newButtonObj.transform; + newHorizLayout.transform.localPosition = Vector3.zero; newHorizLayout.transform.localScale = Vector3.one; newHorizLayout.transform.localRotation = Quaternion.identity; @@ -561,6 +571,7 @@ public SubmitAction CreateButtonWithLabel(Menu menu, string label, string button var newButton = Object.Instantiate(existingButton); newButton.transform.parent = controlBlock; newButton.transform.localScale = Vector3.one; + newButton.transform.localPosition = Vector3.zero; newButton.name = $"UIElement-{label}"; newButton.transform.localRotation = Quaternion.identity; @@ -690,10 +701,12 @@ public void CreateLabel(Menu menu, string label) textObj.transform.parent = newObj.transform; textObj.transform.localScale = Vector3.one; textObj.transform.localPosition = Vector3.zero; + textObj.transform.localRotation = Quaternion.identity; newObj.transform.parent = GetParentForAddedElements(menu); newObj.transform.localScale = Vector3.one; newObj.transform.localPosition = Vector3.zero; + newObj.transform.localRotation = Quaternion.identity; } private TabButton CreateTabButton(string name, Menu menu) @@ -703,6 +716,7 @@ private TabButton CreateTabButton(string name, Menu menu) var newButton = Object.Instantiate(existingButton); newButton.transform.parent = existingButton.transform.parent; newButton.transform.localScale = Vector3.one; + newButton.transform.localPosition = Vector3.zero; newButton.transform.SetSiblingIndex(newButton.transform.parent.childCount - 2); newButton.name = $"Button-{name}"; newButton.transform.localRotation = Quaternion.identity; diff --git a/src/OWML.ModHelper.Menus/NewMenuSystem/TitleMenuManager.cs b/src/OWML.ModHelper.Menus/NewMenuSystem/TitleMenuManager.cs index 472c14f5..fac32ceb 100644 --- a/src/OWML.ModHelper.Menus/NewMenuSystem/TitleMenuManager.cs +++ b/src/OWML.ModHelper.Menus/NewMenuSystem/TitleMenuManager.cs @@ -19,6 +19,7 @@ public SubmitAction CreateTitleButton(string text, int index, bool fromTop) newButton.transform.parent = existingTitleButton.transform.parent; newButton.transform.localScale = existingTitleButton.transform.localScale; newButton.transform.localRotation = Quaternion.identity; + newButton.transform.localPosition = Vector3.zero; newButton.name = $"Button-{text}"; Object.Destroy(newButton.GetComponent());