public static void Postfix(ComboUIController __instance) { RectTransform textTransform = __instance.transform.Find("ComboText") as RectTransform; if (!textTransform) { return; } GameObject textObject = textTransform.gameObject; bool wasActive = textObject.activeSelf; textObject.SetActive(false); TextMeshProUGUI text = textObject.GetComponent <CurvedTextMeshPro>(); text.fontStyle |= FontStyles.UpperCase; text.alignment = TextAlignmentOptions.Baseline; var offset = new Vector2(0, 6); textTransform.offsetMin -= offset; textTransform.offsetMax -= offset; textTransform.sizeDelta = new Vector2(180, textTransform.sizeDelta.y); LocalizedTextMeshProUGUI localizedText = textObject.AddComponent <LocalizedTextMeshProUGUI>(); localizedText.SetField <LocalizedTextComponent <TextMeshProUGUI>, TextMeshProUGUI>("localizedComponent", text); localizedText.Key = "LABEL_COMBO"; textObject.SetActive(wasActive); }
public override GameObject CreateObject(Transform parent) { if (buttonPrefab == null) { buttonPrefab = Resources.FindObjectsOfTypeAll <Button>().Last(x => (x.name == PrefabButton)); } Button button = MonoBehaviour.Instantiate(buttonPrefab, parent, false); button.name = "BSMLButton"; button.interactable = true; ExternalComponents externalComponents = button.gameObject.AddComponent <ExternalComponents>(); GameObject textObject = button.transform.Find("Content/Text").gameObject; LocalizedTextMeshProUGUI localizedText = ConfigureLocalizedText(textObject); externalComponents.components.Add(localizedText); TextMeshProUGUI textMesh = textObject.GetComponent <TextMeshProUGUI>(); textMesh.text = "Default Text"; textMesh.richText = true; externalComponents.components.Add(textMesh); GameObject.Destroy(button.transform.Find("Content").GetComponent <LayoutElement>()); ContentSizeFitter buttonSizeFitter = button.gameObject.AddComponent <ContentSizeFitter>(); buttonSizeFitter.verticalFit = ContentSizeFitter.FitMode.PreferredSize; buttonSizeFitter.horizontalFit = ContentSizeFitter.FitMode.PreferredSize; LayoutGroup stackLayoutGroup = button.GetComponentInChildren <LayoutGroup>(); if (stackLayoutGroup != null) { externalComponents.components.Add(stackLayoutGroup); } /* * Image glowImage = button.gameObject.GetComponentsInChildren<Image>(true).Where(x => x.gameObject.name == "Glow").FirstOrDefault(); * if (glowImage != null) * { * Glowable glowable = button.gameObject.AddComponent<Glowable>(); * glowable.image = glowImage; * glowable.SetGlow("none"); * } * * Image strokeImage = button.gameObject.GetComponentsInChildren<Image>(true).Where(x => x.gameObject.name == "Stroke").FirstOrDefault(); * if (strokeImage != null) * { * Strokable strokable = button.gameObject.AddComponent<Strokable>(); * strokable.image = strokeImage; * strokable.SetType(StrokeType.Regular); * }*/ return(button.gameObject); }
protected LocalizedTextMeshProUGUI ConfigureLocalizedText(GameObject gameObject) { LocalizedTextMeshProUGUI localizedText = gameObject.GetComponent <LocalizedTextMeshProUGUI>(); localizedText.enabled = false; localizedText.Key = string.Empty; return(localizedText); }
protected LocalizedTextMeshProUGUI ConfigureLocalizedText(GameObject gameObject) { LocalizedTextMeshProUGUI localizedText = gameObject.GetComponent <LocalizedTextMeshProUGUI>(); localizedText.enabled = false; localizedText.Key = string.Empty; Localization.Instance.RemoveOnLocalizeEvent(localizedText); return(localizedText); }
private void AddMenuOption() { Transform dropdownTemplate = _gameplaySetupViewController.transform.Find("EnvironmentOverrideSettings/Settings/Elements/NormalLevels"); Transform otherSettingsContent = _settingsNavigationController.transform.Find("OtherSettings/Content"); if (!dropdownTemplate) { Plugin.Log.Error("Dropdown template not found!"); return; } if (!otherSettingsContent) { Plugin.Log.Error("OtherSettings/Content not found!"); return; } GameObject gameObject = _container.InstantiatePrefab(dropdownTemplate.gameObject, otherSettingsContent); gameObject.name = "LanguageSetting"; RectTransform rectTransform = gameObject.GetComponent <RectTransform>(); rectTransform.offsetMin = new Vector2(0, -14.2f); rectTransform.offsetMax = new Vector2(0, -7.2f); LocalizedTextMeshProUGUI label = gameObject.transform.Find("Label").GetComponent <LocalizedTextMeshProUGUI>(); label.Key = "SETTINGS_LANGUAGE"; _languageSetting = _container.InstantiateComponent <LanguageSetting>(gameObject); Plugin.Log.Debug("Created language setting"); var textGameObject = new GameObject("SiraLocalizerContributorsText"); _credits = textGameObject.AddComponent <CurvedTextMeshPro>(); _credits.fontMaterial = label.gameObject.GetComponent <CurvedTextMeshPro>().fontMaterial; var textRectTransform = (RectTransform)textGameObject.transform; textRectTransform.SetParent(otherSettingsContent, false); textRectTransform.offsetMin = new Vector2(-45f, -14.4f); textRectTransform.offsetMax = new Vector2(45f, -7.4f); _credits.alignment = TextAlignmentOptions.TopLeft; _credits.lineSpacing = -35f; _credits.fontSize = 3f; _credits.fontStyle = FontStyles.Italic; }
public override GameObject CreateObject(Transform parent) { if (valueControllerTemplate == null) { valueControllerTemplate = Resources.FindObjectsOfTypeAll <FormattedFloatListSettingsValueController>().First(x => x.name == "VRRenderingScale"); } FormattedFloatListSettingsValueController baseSetting = Object.Instantiate(valueControllerTemplate, parent, false); baseSetting.name = "BSMLSliderSetting"; GameObject gameObject = baseSetting.gameObject; T sliderSetting = gameObject.AddComponent <T>(); Object.Destroy(gameObject.transform.Find("ValuePicker").gameObject); if (timeSliderTemplate == null) { timeSliderTemplate = Resources.FindObjectsOfTypeAll <TimeSlider>().First(s => s.name == "RangeValuesTextSlider" && s.transform.parent?.name == "SongStart"); } sliderSetting.slider = Object.Instantiate(timeSliderTemplate, gameObject.transform, false); sliderSetting.slider.name = "BSMLSlider"; sliderSetting.slider.GetComponentInChildren <TextMeshProUGUI>().enableWordWrapping = false; (sliderSetting.slider.transform as RectTransform).anchorMin = new Vector2(1, 0); (sliderSetting.slider.transform as RectTransform).anchorMax = new Vector2(1, 1); (sliderSetting.slider.transform as RectTransform).sizeDelta = new Vector2(40, 0); (sliderSetting.slider.transform as RectTransform).pivot = new Vector2(1, 0.5f); (sliderSetting.slider.transform as RectTransform).anchoredPosition = new Vector2(0, 0); Object.Destroy(baseSetting); GameObject nameText = gameObject.transform.Find("NameText").gameObject; LocalizedTextMeshProUGUI localizedText = ConfigureLocalizedText(nameText); TextMeshProUGUI text = nameText.GetComponent <TextMeshProUGUI>(); text.text = "Default Text"; List <Component> externalComponents = gameObject.AddComponent <ExternalComponents>().components; externalComponents.Add(text); externalComponents.Add(localizedText); gameObject.GetComponent <LayoutElement>().preferredWidth = 90; gameObject.SetActive(true); return(gameObject); }
public override GameObject CreateObject(Transform parent) { if (toggleTemplate == null) { toggleTemplate = Resources.FindObjectsOfTypeAll <Toggle>().Select(x => x.transform.parent.gameObject).First(p => p.name == PrefabToggleName); templateController = toggleTemplate.GetComponent <BoolSettingsController>(); templateControllerToggle = templateController.GetComponentInChildren <Toggle>(); } templateController.enabled = false; templateControllerToggle.isOn = false; GameObject gameObject = Object.Instantiate(toggleTemplate, parent, false); GameObject nameText = gameObject.transform.Find("NameText").gameObject; Object.Destroy(gameObject.GetComponent <BoolSettingsController>()); templateController.enabled = true; templateControllerToggle.isOn = true; gameObject.name = "BSMLToggle"; gameObject.SetActive(false); ToggleSetting toggleSetting = gameObject.AddComponent <ToggleSetting>(); toggleSetting.toggle = gameObject.GetComponentInChildren <Toggle>(); toggleSetting.toggle.interactable = true; toggleSetting.toggle.isOn = false; toggleSetting.toggle.onValueChanged.RemoveAllListeners(); LocalizedTextMeshProUGUI localizedText = ConfigureLocalizedText(nameText); toggleSetting.text = nameText.GetComponent <TextMeshProUGUI>(); toggleSetting.text.text = "Default Text"; toggleSetting.text.richText = true; toggleSetting.text.overflowMode = TextOverflowModes.Ellipsis; List <Component> externalComponents = gameObject.AddComponent <ExternalComponents>().components; externalComponents.Add(toggleSetting.text); externalComponents.Add(localizedText); gameObject.GetComponent <LayoutElement>().preferredWidth = 90; gameObject.SetActive(true); return(gameObject); }
public override GameObject CreateObject(Transform parent) { if (controllersTransformTemplate == null) { controllersTransformTemplate = Resources.FindObjectsOfTypeAll <LayoutElement>().First(x => x.name == "PositionX"); } LayoutElement baseSetting = Object.Instantiate(controllersTransformTemplate, parent, false); baseSetting.name = "BSMLSliderSetting"; GameObject gameObject = baseSetting.gameObject; T sliderSetting = gameObject.AddComponent <T>(); sliderSetting.slider = baseSetting.GetComponentInChildren <CustomFormatRangeValuesSlider>(); sliderSetting.slider.name = "BSMLSlider"; sliderSetting.slider.GetComponentInChildren <TextMeshProUGUI>().enableWordWrapping = false; (sliderSetting.slider as TextSlider).SetField("_enableDragging", true); (sliderSetting.slider.transform as RectTransform).anchorMin = new Vector2(1, 0); (sliderSetting.slider.transform as RectTransform).anchorMax = new Vector2(1, 1); (sliderSetting.slider.transform as RectTransform).sizeDelta = new Vector2(52, 0); (sliderSetting.slider.transform as RectTransform).pivot = new Vector2(1, 0.5f); (sliderSetting.slider.transform as RectTransform).anchoredPosition = new Vector2(0, 0); GameObject nameText = gameObject.transform.Find("Title").gameObject; LocalizedTextMeshProUGUI localizedText = ConfigureLocalizedText(nameText); TextMeshProUGUI text = nameText.GetComponent <TextMeshProUGUI>(); text.text = "Default Text"; text.rectTransform.anchorMax = Vector2.one; List <Component> externalComponents = gameObject.AddComponent <ExternalComponents>().components; externalComponents.Add(text); externalComponents.Add(localizedText); baseSetting.preferredWidth = 90; gameObject.SetActive(true); return(gameObject); }
public override GameObject CreateObject(Transform parent) { if (valueControllerTemplate == null) { valueControllerTemplate = Resources.FindObjectsOfTypeAll <FormattedFloatListSettingsValueController>().First(x => x.name == "VRRenderingScale"); } FormattedFloatListSettingsValueController baseSetting = Object.Instantiate(valueControllerTemplate, parent, false); baseSetting.name = "BSMLIncDecSetting"; GameObject gameObject = baseSetting.gameObject; Object.Destroy(baseSetting); gameObject.SetActive(false); T boolSetting = gameObject.AddComponent <T>(); boolSetting.text = gameObject.transform.GetChild(1).GetComponentsInChildren <TextMeshProUGUI>().First(); boolSetting.text.richText = true; boolSetting.decButton = gameObject.transform.GetChild(1).GetComponentsInChildren <Button>().First(); boolSetting.incButton = gameObject.transform.GetChild(1).GetComponentsInChildren <Button>().Last(); (gameObject.transform.GetChild(1) as RectTransform).sizeDelta = new Vector2(40, 0); boolSetting.text.overflowMode = TextOverflowModes.Ellipsis; GameObject nameText = gameObject.transform.Find("NameText").gameObject; LocalizedTextMeshProUGUI localizedText = ConfigureLocalizedText(nameText); TextMeshProUGUI text = nameText.GetComponent <TextMeshProUGUI>(); text.text = "Default Text"; text.richText = true; List <Component> externalComponents = gameObject.AddComponent <ExternalComponents>().components; externalComponents.Add(text); externalComponents.Add(localizedText); gameObject.GetComponent <LayoutElement>().preferredWidth = 90; gameObject.SetActive(true); return(gameObject); }
public override GameObject CreateObject(Transform parent) { GameObject gameObject = Object.Instantiate(safePrefab, parent, false); gameObject.name = "BSMLDropdownList"; SimpleTextDropdown dropdown = gameObject.GetComponentInChildren <SimpleTextDropdown>(); dropdown.gameObject.SetActive(false); dropdown.name = "Dropdown"; dropdown.GetComponentInChildren <VRGraphicRaycaster>(true).SetField("_physicsRaycaster", BeatSaberUI.PhysicsRaycasterWithCache); dropdown.GetComponentInChildren <ModalView>(true).SetField("_container", BeatSaberUI.DiContainer); dropdown.GetComponentInChildren <ScrollView>(true).SetField("_platformHelper", BeatSaberUI.PlatformHelper); GameObject labelObject = gameObject.transform.Find("Label").gameObject; LocalizedTextMeshProUGUI localizedText = ConfigureLocalizedText(labelObject); CurvedTextMeshPro textMesh = labelObject.GetComponent <CurvedTextMeshPro>(); textMesh.text = "Default Text"; LayoutElement layoutElement = gameObject.AddComponent <LayoutElement>(); layoutElement.preferredHeight = 8; layoutElement.preferredWidth = 90; List <Component> externalComponents = dropdown.gameObject.AddComponent <ExternalComponents>().components; externalComponents.Add(textMesh); externalComponents.Add(localizedText); externalComponents.Add(layoutElement); DropDownListSetting dropDownListSetting = dropdown.gameObject.AddComponent <DropDownListSetting>(); dropDownListSetting.dropdown = dropdown; dropdown.gameObject.SetActive(true); gameObject.SetActive(true); return(dropdown.gameObject); }
public override GameObject CreateObject(Transform parent) { FormattedFloatListSettingsValueController baseSetting = MonoBehaviour.Instantiate(Resources.FindObjectsOfTypeAll <FormattedFloatListSettingsValueController>().First(x => (x.name == "VRRenderingScale")), parent, false); baseSetting.name = "BSMLColorSetting"; GameObject gameObject = baseSetting.gameObject; gameObject.SetActive(false); MonoBehaviour.Destroy(baseSetting); ColorSetting colorSetting = gameObject.AddComponent <ColorSetting>(); Transform valuePick = gameObject.transform.Find("ValuePicker"); (valuePick.transform as RectTransform).sizeDelta = new Vector2(13, 0); Button decButton = valuePick.GetComponentsInChildren <Button>().First(); decButton.enabled = false; decButton.interactable = true; GameObject.Destroy(decButton.transform.Find("Icon").gameObject); GameObject.Destroy(valuePick.GetComponentsInChildren <TextMeshProUGUI>().First().gameObject); colorSetting.editButton = valuePick.GetComponentsInChildren <Button>().Last(); GameObject nameText = gameObject.transform.Find("NameText").gameObject; LocalizedTextMeshProUGUI localizedText = ConfigureLocalizedText(nameText); TextMeshProUGUI text = nameText.GetComponent <TextMeshProUGUI>(); text.text = "Default Text"; List <Component> externalComponents = gameObject.AddComponent <ExternalComponents>().components; externalComponents.Add(text); externalComponents.Add(localizedText); gameObject.GetComponent <LayoutElement>().preferredWidth = 90; Image colorImage = Object.Instantiate(Resources.FindObjectsOfTypeAll <Image>().First(x => x.gameObject.name == "ColorImage" && x.sprite?.name == "NoteCircle"), valuePick, false); colorImage.name = "BSMLCurrentColor"; (colorImage.gameObject.transform as RectTransform).anchoredPosition = new Vector2(0, 0); (colorImage.gameObject.transform as RectTransform).sizeDelta = new Vector2(5, 5); (colorImage.gameObject.transform as RectTransform).anchorMin = new Vector2(0.2f, 0.5f); (colorImage.gameObject.transform as RectTransform).anchorMax = new Vector2(0.2f, 0.5f); colorSetting.colorImage = colorImage; Image icon = colorSetting.editButton.transform.Find("Icon").GetComponent <Image>(); icon.name = "EditIcon"; icon.sprite = Utilities.EditIcon; icon.rectTransform.sizeDelta = new Vector2(4, 4); colorSetting.editButton.interactable = true; (colorSetting.editButton.transform as RectTransform).anchorMin = new Vector2(0, 0); colorSetting.modalColorPicker = base.CreateObject(gameObject.transform).GetComponent <ModalColorPicker>(); gameObject.SetActive(true); return(gameObject); }
private void AddMenuOption() { Transform dropdownTemplate = _gameplaySetupViewController.transform.Find("EnvironmentOverrideSettings/Settings/Elements/NormalLevels"); Transform otherSettingsContent = _settingsNavigationController.transform.Find("OtherSettings/Content"); if (!dropdownTemplate) { Plugin.Log.Error("Dropdown template not found!"); return; } if (!otherSettingsContent) { Plugin.Log.Error("OtherSettings/Content not found!"); return; } GameObject gameObject = _container.InstantiatePrefab(dropdownTemplate.gameObject, otherSettingsContent); gameObject.name = "LanguageSetting"; RectTransform rectTransform = gameObject.GetComponent <RectTransform>(); rectTransform.offsetMin = new Vector2(0, -14.2f); rectTransform.offsetMax = new Vector2(0, -7.2f); LocalizedTextMeshProUGUI label = gameObject.transform.Find("Label").GetComponent <LocalizedTextMeshProUGUI>(); label.Key = "SETTINGS_LANGUAGE"; _container.InstantiateComponent <LanguageSetting>(gameObject); Plugin.Log.Debug("Created language setting"); var textGameObject = new GameObject("SiraLocalizerContributorsText"); _credits = textGameObject.AddComponent <CurvedTextMeshPro>(); var textRectTransform = (RectTransform)textGameObject.transform; textRectTransform.SetParent(otherSettingsContent, false); textRectTransform.offsetMin = new Vector2(-45f, -7.4f); textRectTransform.offsetMax = new Vector2(45f, -7.4f); _credits.alignment = TextAlignmentOptions.TopLeft; _credits.lineSpacing = -35f; _credits.fontSize = 3f; _credits.fontStyle = FontStyles.Italic; _credits.gameObject.SetActive(false); foreach (var lang in Localization.Instance.SupportedLanguages) { if (lang == Language.English) { continue; } var contributors = Localization.Get("LANGUAGE_CONTRIBUTORS", lang); var name = Localization.Get("MENU_LANGUAGE_THIS", lang); if (!string.IsNullOrEmpty(contributors)) { _credits.text += $"<b>{name}</b> <color=#bababa>{contributors}</color>\n"; } } _creditsToggle = _container.InstantiatePrefabForComponent <Button>(_standardLevelDetailViewController.GetField <StandardLevelDetailView, StandardLevelDetailViewController>("_standardLevelDetailView").practiceButton); _creditsToggle.name = "LocalizationCreditsButton"; UnityEngine.Object.Destroy(_creditsToggle.transform.Find("Content").GetComponent <LayoutElement>()); _creditsToggle.gameObject.transform.SetParent(otherSettingsContent, false); var rect = (_creditsToggle.transform as RectTransform); rect.localPosition = new Vector3(-5f, -11f, 0f); ContentSizeFitter buttonSizeFitter = _creditsToggle.gameObject.AddComponent <ContentSizeFitter>(); buttonSizeFitter.verticalFit = ContentSizeFitter.FitMode.PreferredSize; buttonSizeFitter.horizontalFit = ContentSizeFitter.FitMode.PreferredSize; LocalizedTextMeshProUGUI localizer = _creditsToggle.GetComponentInChildren <LocalizedTextMeshProUGUI>(true); localizer.Key = "CREDITS_TITLE"; _creditsToggle.onClick.AddListener(ToggleCredits); }
public override GameObject CreateObject(Transform parent) { if (valueControllerTemplate == null) { valueControllerTemplate = Resources.FindObjectsOfTypeAll <FormattedFloatListSettingsValueController>().First(x => x.name == "VRRenderingScale"); } FormattedFloatListSettingsValueController baseSetting = Object.Instantiate(valueControllerTemplate, parent, false); baseSetting.name = "BSMLStringSetting"; GameObject gameObject = baseSetting.gameObject; gameObject.SetActive(false); Object.Destroy(baseSetting); StringSetting stringSetting = gameObject.AddComponent <StringSetting>(); Transform valuePick = gameObject.transform.Find("ValuePicker"); Object.Destroy(valuePick.GetComponent <StepValuePicker>()); Button decButton = valuePick.GetComponentsInChildren <Button>().First(); decButton.enabled = false; decButton.interactable = true; Object.Destroy(decButton.transform.Find("Icon").gameObject); stringSetting.text = valuePick.GetComponentsInChildren <TextMeshProUGUI>().First(); stringSetting.text.richText = true; stringSetting.editButton = valuePick.GetComponentsInChildren <Button>().Last(); stringSetting.boundingBox = valuePick as RectTransform; GameObject nameText = gameObject.transform.Find("NameText").gameObject; LocalizedTextMeshProUGUI localizedText = ConfigureLocalizedText(nameText); TextMeshProUGUI text = nameText.GetComponent <TextMeshProUGUI>(); text.text = "Default Text"; List <Component> externalComponents = gameObject.AddComponent <ExternalComponents>().components; externalComponents.Add(text); externalComponents.Add(localizedText); gameObject.GetComponent <LayoutElement>().preferredWidth = 90; stringSetting.text.alignment = TextAlignmentOptions.MidlineRight; stringSetting.text.enableWordWrapping = false; RectTransform textTransform = stringSetting.text.transform as RectTransform; textTransform.anchorMin = new Vector2(0, 0); textTransform.anchorMax = new Vector2(1, 1); textTransform.anchoredPosition = new Vector2(-6, 0); Image icon = stringSetting.editButton.transform.Find("Icon").GetComponent <Image>(); icon.name = "EditIcon"; icon.sprite = Utilities.EditIcon; icon.rectTransform.sizeDelta = new Vector2(4, 4); stringSetting.editButton.interactable = true; (stringSetting.editButton.transform as RectTransform).anchorMin = new Vector2(0, 0); stringSetting.modalKeyboard = base.CreateObject(gameObject.transform).GetComponent <ModalKeyboard>(); gameObject.SetActive(true); return(gameObject); }