Skip to content

Commit

Permalink
edit localposition and fix label rotation
Browse files Browse the repository at this point in the history
  • Loading branch information
misternebula committed Mar 19, 2024
1 parent 60856fd commit 82258cf
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/OWML.ModHelper.Menus/NewMenuSystem/OptionsMenuManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<RectTransform>();
var ert = existingMenu.GetComponent<RectTransform>();
Expand Down Expand Up @@ -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>();
rectTransform.anchorMin = existingTabbedSubMenu.GetComponent<RectTransform>().anchorMin;
Expand Down Expand Up @@ -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";
Expand All @@ -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;

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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}";
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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)
Expand All @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/OWML.ModHelper.Menus/NewMenuSystem/TitleMenuManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<SubmitActionConfirm>());
Expand Down

0 comments on commit 82258cf

Please sign in to comment.