public override GameObject CreateObject(Transform parent) { ModalView yoinkFromView = Resources.FindObjectsOfTypeAll <ModalView>().First(x => x.name == "DropdownTableView"); ModalView modalView = GameObject.Instantiate(yoinkFromView, parent); modalView.SetField("_presentPanelAnimations", yoinkFromView.GetField <PanelAnimationSO, ModalView>("_presentPanelAnimations")); modalView.SetField("_dismissPanelAnimation", yoinkFromView.GetField <PanelAnimationSO, ModalView>("_dismissPanelAnimation")); modalView.SetField("_container", BeatSaberUI.DiContainer); modalView.GetComponent <VRGraphicRaycaster>().SetField("_physicsRaycaster", BeatSaberUI.PhysicsRaycasterWithCache); GameObject.Destroy(modalView.GetComponent <TableView>()); GameObject.Destroy(modalView.GetComponent <TableViewScroller>()); GameObject.Destroy(modalView.GetComponent <ScrollRect>()); foreach (RectTransform child in modalView.transform) { if (child.name == "BG") { child.anchoredPosition = Vector2.zero; child.sizeDelta = Vector2.zero; } else { GameObject.Destroy(child.gameObject); } } RectTransform rectTransform = modalView.transform as RectTransform; rectTransform.anchorMin = new Vector2(0.5f, 0.5f); rectTransform.anchorMax = new Vector2(0.5f, 0.5f); rectTransform.sizeDelta = new Vector2(0, 0); return(modalView.gameObject); }
public override GameObject CreateObject(Transform parent) { GameObject gameObject = new GameObject(); gameObject.SetActive(false); gameObject.name = "BSMLModalView"; RectTransform rectTransform = gameObject.AddComponent <RectTransform>(); rectTransform.SetParent(parent, false); rectTransform.anchorMin = new Vector2(0.5f, 0.5f); rectTransform.anchorMax = new Vector2(0.5f, 0.5f); rectTransform.sizeDelta = new Vector2(0, 0); ModalView modalView = gameObject.AddComponent <ModalView>(); ModalView yoinkFromView = Resources.FindObjectsOfTypeAll <ModalView>().First(x => x.name == "TableView"); modalView.SetField("_presentPanelAnimations", yoinkFromView.GetField <PanelAnimationSO, ModalView>("_presentPanelAnimations")); modalView.SetField("_dismissPanelAnimation", yoinkFromView.GetField <PanelAnimationSO, ModalView>("_dismissPanelAnimation")); GameObject child = new GameObject(); child.transform.SetParent(rectTransform, false); child.name = "Shadow"; RectTransform shadowTransform = child.gameObject.AddComponent <RectTransform>(); shadowTransform.anchorMin = new Vector2(0, 0); shadowTransform.anchorMax = new Vector2(1, 1); shadowTransform.sizeDelta = new Vector2(10, 10); child.gameObject.AddComponent <Backgroundable>().ApplyBackground("round-rect-panel-shadow"); child = new GameObject(); child.transform.SetParent(rectTransform, false); child.name = "Content"; RectTransform backgroundTransform = child.gameObject.AddComponent <RectTransform>(); backgroundTransform.anchorMin = new Vector2(0, 0); backgroundTransform.anchorMax = new Vector2(1, 1); backgroundTransform.sizeDelta = new Vector2(0, 0); Backgroundable backgroundable = child.gameObject.AddComponent <Backgroundable>(); backgroundable.ApplyBackground("round-rect-panel"); backgroundable.background.color = new Color(0.706f, 0.706f, 0.706f, 1); backgroundable.background.material = Resources.FindObjectsOfTypeAll <Material>().First(x => x.name == "UIFogBG"); ExternalComponents externalComponents = child.AddComponent <ExternalComponents>(); externalComponents.components.Add(modalView); externalComponents.components.Add(rectTransform); return(child); }
public override GameObject CreateObject(Transform parent) { if (modalViewTemplate == null) { modalViewTemplate = Resources.FindObjectsOfTypeAll <ModalView>().First(x => x.name == "DropdownTableView"); } ModalView modalView = Object.Instantiate(modalViewTemplate, parent); modalView.SetField("_presentPanelAnimations", modalViewTemplate.GetField <PanelAnimationSO, ModalView>("_presentPanelAnimations")); modalView.SetField("_dismissPanelAnimation", modalViewTemplate.GetField <PanelAnimationSO, ModalView>("_dismissPanelAnimation")); modalView.SetField("_container", BeatSaberUI.DiContainer); modalView.GetComponent <VRGraphicRaycaster>().SetField("_physicsRaycaster", BeatSaberUI.PhysicsRaycasterWithCache); Object.DestroyImmediate(modalView.GetComponent <TableView>()); Object.DestroyImmediate(modalView.GetComponent <ScrollRect>()); Object.DestroyImmediate(modalView.GetComponent <ScrollView>()); Object.DestroyImmediate(modalView.GetComponent <EventSystemListener>()); //GameObject.DestroyImmediate(modalView.GetComponent<Touchable>()); //modalView.gameObject.AddComponent<CurvedCanvasSettings>(); //modalView.gameObject.AddComponent<EventSystemListener>(); foreach (RectTransform child in modalView.transform) { if (child.name == "BG") { child.anchoredPosition = Vector2.zero; child.sizeDelta = Vector2.zero; } else { Object.Destroy(child.gameObject); } } RectTransform rectTransform = modalView.transform as RectTransform; rectTransform.anchorMin = new Vector2(0.5f, 0.5f); rectTransform.anchorMax = new Vector2(0.5f, 0.5f); rectTransform.sizeDelta = new Vector2(0, 0); return(modalView.gameObject); }
private void Parse() { if (!parsed) { BSMLParser.instance.Parse(BeatSaberMarkupLanguage.Utilities.GetResourceContent(Assembly.GetExecutingAssembly(), "PlaylistManager.UI.Views.ImageSelectionModal.bsml"), levelPackDetailViewController.transform.Find("Detail").gameObject, this); modalPosition = modalTransform.position; modalView.SetField("_animateParentCanvas", false); parsed = true; } modalTransform.position = modalPosition; }
private void Parse() { if (!parsed) { BSMLParser.instance.Parse(BeatSaberMarkupLanguage.Utilities.GetResourceContent(Assembly.GetExecutingAssembly(), "PlaylistManager.UI.Views.PlaylistDetailsView.bsml"), levelPackDetailViewController.transform.Find("Detail").gameObject, this); modalPosition = modalTransform.position; ModalView nameKeyboardModal = nameSettingTransform.Find("BSMLModalKeyboard").GetComponent <ModalView>(); nameKeyboardModal.SetField("_animateParentCanvas", false); ModalView authorKeyboardModal = authorSettingTransform.Find("BSMLModalKeyboard").GetComponent <ModalView>(); authorKeyboardModal.SetField("_animateParentCanvas", false); parsed = true; } modalTransform.position = modalPosition; }
// Methods internal void ShowYesNoModal(Transform parent, string text, ButtonPressed yesButtonPressedCallback, string yesButtonText = "Yes", string noButtonText = "No", ButtonPressed noButtonPressedCallback = null, bool animateParentCanvas = true, string checkboxText = "") { Parse(); yesNoModalTransform.position = yesNoModalPosition; keyboardTransform.transform.SetParent(rootTransform); yesNoModalTransform.transform.SetParent(parent); YesNoText = text; YesButtonText = yesButtonText; NoButtonText = noButtonText; yesButtonPressed = yesButtonPressedCallback; noButtonPressed = noButtonPressedCallback; CheckboxText = checkboxText; CheckboxValue = false; CheckboxActive = !string.IsNullOrEmpty(checkboxText); yesNoModalView.SetField("_animateParentCanvas", animateParentCanvas); parserParams.EmitEvent("close-yes-no"); parserParams.EmitEvent("open-yes-no"); }