Ejemplo n.º 1
0
        public override GameObject CreateObject(Transform parent)
        {
            BoolSettingsController baseSetting = MonoBehaviour.Instantiate(Resources.FindObjectsOfTypeAll <BoolSettingsController>().First(x => (x.name == "Fullscreen")), parent, false);

            baseSetting.name = "BSMLIncDecSetting";

            GameObject gameObject = baseSetting.gameObject;

            MonoBehaviour.Destroy(baseSetting);
            gameObject.SetActive(false);

            T boolSetting = gameObject.AddComponent <T>();

            boolSetting.text      = gameObject.transform.GetChild(1).GetComponentsInChildren <TextMeshProUGUI>().First();
            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;

            TextMeshProUGUI text = gameObject.GetComponentInChildren <TextMeshProUGUI>();

            text.text = "Default Text";
            gameObject.AddComponent <ExternalComponents>().components.Add(text);
            MonoBehaviour.Destroy(text.GetComponent <LocalizedTextMeshProUGUI>());

            gameObject.GetComponent <LayoutElement>().preferredWidth = 90;

            gameObject.SetActive(true);
            return(gameObject);
        }
Ejemplo n.º 2
0
        public override GameObject CreateObject(Transform parent)
        {
            BoolSettingsController baseSetting = MonoBehaviour.Instantiate(Resources.FindObjectsOfTypeAll <BoolSettingsController>().First(x => (x.name == "Fullscreen")), parent, false);

            baseSetting.name = "BSMLSliderSetting";

            GameObject gameObject = baseSetting.gameObject;

            T         sliderSetting = gameObject.AddComponent <T>();
            Transform valuePick     = gameObject.transform.Find("ValuePicker");

            sliderSetting.slider      = GameObject.Instantiate(Resources.FindObjectsOfTypeAll <HMUI.TimeSlider>().First(s => s.name != "BSMLSlider"), valuePick, false);
            sliderSetting.slider.name = "BSMLSlider";
            sliderSetting.slider.GetComponentInChildren <TextMeshProUGUI>().enableWordWrapping = false;
            (sliderSetting.slider.transform as RectTransform).anchorMin = new Vector2(-0.2f, 0.4f);
            (sliderSetting.slider.transform as RectTransform).anchorMax = new Vector2(1, 1.2f);
            (sliderSetting.slider.transform as RectTransform).sizeDelta = new Vector2(0, 0);

            MonoBehaviour.Destroy(baseSetting);
            GameObject.Destroy(valuePick.GetComponentsInChildren <TextMeshProUGUI>().First().transform.parent.gameObject);
            GameObject.Destroy(valuePick.GetComponentsInChildren <Button>().First().gameObject);
            GameObject.Destroy(valuePick.GetComponentsInChildren <Button>().Last().gameObject);

            TextMeshProUGUI text = gameObject.GetComponentInChildren <TextMeshProUGUI>();

            text.text = "Default Text";
            gameObject.AddComponent <ExternalComponents>().components.Add(text);
            MonoBehaviour.Destroy(text.GetComponent <LocalizedTextMeshProUGUI>());

            gameObject.GetComponent <LayoutElement>().preferredWidth = 90;

            gameObject.SetActive(true);
            return(gameObject);
        }
        public override GameObject CreateObject(Transform parent)
        {
            BoolSettingsController baseSetting = MonoBehaviour.Instantiate(Resources.FindObjectsOfTypeAll <BoolSettingsController>().First(x => (x.name == "Fullscreen")), 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("Arrow").gameObject);
            GameObject.Destroy(valuePick.GetComponentsInChildren <TextMeshProUGUI>().First().gameObject);
            colorSetting.editButton = valuePick.GetComponentsInChildren <Button>().Last();

            TextMeshProUGUI text = gameObject.GetComponentInChildren <TextMeshProUGUI>();

            text.text = "Default Text";
            gameObject.AddComponent <ExternalComponents>().components.Add(text);
            MonoBehaviour.Destroy(text.GetComponent <LocalizedTextMeshProUGUI>());

            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.3f, 0.2f);
            (colorImage.gameObject.transform as RectTransform).anchorMax        = new Vector2(0.3f, 0.2f);
            colorSetting.colorImage = colorImage;

            Image icon = colorSetting.editButton.transform.Find("Arrow").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);
        }
Ejemplo n.º 4
0
        public override GameObject CreateObject(Transform parent)
        {
            BoolSettingsController baseSetting = MonoBehaviour.Instantiate(Resources.FindObjectsOfTypeAll <BoolSettingsController>().First(x => (x.name == "Fullscreen")), parent, false);

            baseSetting.name = "BSMLStringSetting";

            GameObject gameObject = baseSetting.gameObject;

            gameObject.SetActive(false);

            MonoBehaviour.Destroy(baseSetting);
            StringSetting stringSetting = gameObject.AddComponent <StringSetting>();
            Transform     valuePick     = gameObject.transform.Find("ValuePicker");
            Button        decButton     = valuePick.GetComponentsInChildren <Button>().First();

            decButton.enabled      = false;
            decButton.interactable = true;
            GameObject.Destroy(decButton.transform.Find("Arrow").gameObject);
            stringSetting.text        = valuePick.GetComponentsInChildren <TextMeshProUGUI>().First();
            stringSetting.editButton  = valuePick.GetComponentsInChildren <Button>().Last();
            stringSetting.boundingBox = valuePick as RectTransform;

            TextMeshProUGUI text = gameObject.GetComponentInChildren <TextMeshProUGUI>();

            text.text = "Default Text";
            gameObject.AddComponent <ExternalComponents>().components.Add(text);
            MonoBehaviour.Destroy(text.GetComponent <LocalizedTextMeshProUGUI>());

            gameObject.GetComponent <LayoutElement>().preferredWidth = 90;
            stringSetting.text.alignment          = TextAlignmentOptions.MidlineRight;
            stringSetting.text.enableWordWrapping = false;

            Image icon = stringSetting.editButton.transform.Find("Arrow").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);
        }
        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);
        }