public void Initialize(PopupInputMenu menu) { if (Menu != null) { return; } var parent = menu.transform.parent.gameObject; var parentCopy = GameObject.Instantiate(parent); parentCopy.AddComponent <DontDestroyOnLoad>(); _inputMenu = parentCopy.transform.GetComponentInChildren <PopupInputMenu>(true); GameObject.Destroy(_inputMenu.GetValue <Text>("_labelText").GetComponent <LocalizedText>()); Initialize((Menu)_inputMenu); }
public void Initialize(PopupInputMenu menu) { if (Menu != null) { return; } var parentCopy = Object.Instantiate(menu.transform.parent.gameObject); parentCopy.AddComponent <DontDestroyOnLoad>(); _twoButtonPopup = parentCopy.transform.Find("TwoButton-Popup")?.GetComponent <PopupMenu>(); if (_twoButtonPopup == null) { Console.WriteLine("Error: Failed to setup warning popup"); } var originalMenu = parentCopy.transform.GetComponentInChildren <PopupInputMenu>(true); // InputField-Popup var menuTransform = originalMenu.GetComponentInChildren <VerticalLayoutGroup>(true).transform; // InputFieldElements var buttonsTransform = menuTransform.GetComponentInChildren <HorizontalLayoutGroup>(true).transform; var buttons = buttonsTransform.GetComponentsInChildren <Button>(true).ToList(); buttons.ForEach(button => button.navigation = new Navigation { mode = Navigation.Mode.None }); var tabbedNavigations = menuTransform.GetComponentsInChildren <TabbedNavigation>(true).ToList(); tabbedNavigations.ForEach(Object.Destroy); var resetButtonObject = CreateResetButton(buttonsTransform); ModLayoutManager layout = null; var inputObject = menuTransform.GetComponentInChildren <InputField>(true).gameObject; // InputField Object.Destroy(inputObject.GetComponent <InputField>()); foreach (Transform child in inputObject.transform) { if (child.name == "BorderImage") { layout = CreateLayoutManager(child.gameObject, resetButtonObject.transform); } else { Object.Destroy(child.gameObject); } } if (layout == null) { OwmlConsole.WriteLine("Error: failed to create combination visualizer in combination editor"); return; } var inputSelectable = inputObject.AddComponent <Selectable>(); _inputMenu = originalMenu.gameObject.AddComponent <ModInputCombinationPopup>(); var submitAction = resetButtonObject.GetComponent <SubmitAction>(); var imageElement = resetButtonObject.GetComponent <ButtonWithHotkeyImageElement>(); _inputMenu.Initialize(originalMenu, inputSelectable, submitAction, imageElement, layout, _inputHandler); Object.Destroy(originalMenu); Object.Destroy(_inputMenu.GetValue <Text>("_labelText").GetComponent <LocalizedText>()); Initialize(_inputMenu); }