Пример #1
0
        public static GameObject CreateButton(Resources resources)
        {
            GameObject buttonRoot = CreateUIElementRoot("Button", s_ThickElementSize);

            GameObject childText = new GameObject("Text (RubyTMP)");

            childText.AddComponent <RectTransform>();
            SetParentAndAlign(childText, buttonRoot);

            Image image = buttonRoot.AddComponent <Image>();

            image.sprite = resources.standard;
            image.type   = Image.Type.Sliced;
            image.color  = s_DefaultSelectableColor;

            Button bt = buttonRoot.AddComponent <Button>();

            SetDefaultColorTransitionValues(bt);

            RubyTextMeshProUGUI text = childText.AddComponent <RubyTextMeshProUGUI>();

            text.text      = "Button";
            text.alignment = TextAlignmentOptions.Center;
            SetDefaultTextValues(text);

            RectTransform textRectTransform = childText.GetComponent <RectTransform>();

            textRectTransform.anchorMin = Vector2.zero;
            textRectTransform.anchorMax = Vector2.one;
            textRectTransform.sizeDelta = Vector2.zero;

            return(buttonRoot);
        }
Пример #2
0
        public static GameObject CreateText(Resources resources)
        {
            GameObject go = CreateUIElementRoot("Text (RubyTMP)", s_ThickElementSize);

            RubyTextMeshProUGUI lbl = go.AddComponent <RubyTextMeshProUGUI>();

            lbl.text = "New Text";
            SetDefaultTextValues(lbl);

            return(go);
        }