public override GameObject CreateObject(Transform parent)
        {
            GameObject gameObject = MonoBehaviour.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);

            ExternalComponents externalComponents = dropdown.gameObject.AddComponent <ExternalComponents>();

            GameObject labelObject = gameObject.transform.Find("Label").gameObject;

            MonoBehaviour.Destroy(labelObject.GetComponent <LocalizedTextMeshProUGUI>());
            externalComponents.components.Add(gameObject.transform.Find("Label").GetComponent <CurvedTextMeshPro>());

            LayoutElement layoutElement = gameObject.AddComponent <LayoutElement>();

            layoutElement.preferredHeight = 8;
            layoutElement.preferredWidth  = 90;
            externalComponents.components.Add(layoutElement);

            DropDownListSetting dropDownListSetting = dropdown.gameObject.AddComponent <DropDownListSetting>();

            dropDownListSetting.dropdown = dropdown;
            dropdown.gameObject.SetActive(true);
            gameObject.SetActive(true);
            return(dropdown.gameObject);
        }
Ejemplo n.º 2
0
        public void Awake()
        {
            _dropdown = GetComponentInChildren <SimpleTextDropdown>();
            _settingsNavigationController = GetComponentInParent <SettingsNavigationController>();

            // AsReadOnly to avoid accidentally messing around with values inside Polyglot
            _languages            = Localization.Instance.SupportedLanguages.AsReadOnly();
            _languageDisplayNames = Localization.Instance.LocalizedLanguageNames.AsReadOnly();

            _selectedLanguage = _languageManager.selectedLanguage;
        }
Ejemplo n.º 3
0
        public void Awake()
        {
            _dropdown = GetComponentInChildren <SimpleTextDropdown>();
            _settingsNavigationController = GetComponentInParent <SettingsNavigationController>();

            // AsReadOnly to avoid accidentally messing around with values inside Polyglot
            _languages            = Localization.Instance.SupportedLanguages.Select(l => (Locale)l).ToList().AsReadOnly();
            _languageDisplayNames = Localization.Instance.LocalizedLanguageNames.AsReadOnly();

            _selectedLanguage = _config.language;
            selectedLanguageChanged?.Invoke(_selectedLanguage);
        }
        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);
        }