UnityEngine.UI.DefaultControls.CreateButton C# (CSharp) Method

CreateButton() public static method

public static CreateButton ( Resources resources ) : GameObject
resources UnityEngine.Resources
return UnityEngine.GameObject
        public static GameObject CreateButton(Resources resources)
        {
            GameObject parent = CreateUIElementRoot("Button", s_ThickElementSize);
            GameObject child = new GameObject("Text");
            child.AddComponent<RectTransform>();
            SetParentAndAlign(child, parent);
            Image image = parent.AddComponent<Image>();
            image.sprite = resources.standard;
            image.type = Image.Type.Sliced;
            image.color = s_DefaultSelectableColor;
            SetDefaultColorTransitionValues(parent.AddComponent<Button>());
            Text lbl = child.AddComponent<Text>();
            lbl.text = "Button";
            lbl.alignment = TextAnchor.MiddleCenter;
            SetDefaultTextValues(lbl);
            RectTransform component = child.GetComponent<RectTransform>();
            component.anchorMin = Vector2.zero;
            component.anchorMax = Vector2.one;
            component.sizeDelta = Vector2.zero;
            return parent;
        }