public MyInputField(string name, Sprite sprite, Rect rect) : base(name) { Element = new MyPanel(sprite, rect).Element; var inputScript = Element.AddComponent<InputField>(); var text = new MyText(""); var placeholder = new MyText("Enter Text..."); text.SetAnchor(0, 0, 1, 1); placeholder.SetAnchor(0, 0, 1, 1); text.Element.GetComponent<Text>().alignment = TextAnchor.MiddleLeft; placeholder.Element.GetComponent<Text>().alignment = TextAnchor.MiddleLeft; placeholder.Element.GetComponent<Text>().fontStyle = FontStyle.Italic; placeholder.Element.GetComponent<Text>().color = Color.gray; var rectT = text.Element.GetComponent<RectTransform>(); rectT.offsetMin = new Vector2(10, 5); rectT.offsetMax = new Vector2(-10, -5); rectT = placeholder.Element.GetComponent<RectTransform>(); rectT.offsetMin = new Vector2(10, 5); rectT.offsetMax = new Vector2(-10, -5); AddElement(text); AddElement(placeholder); inputScript.placeholder = placeholder.Element.GetComponent<Text>(); inputScript.textComponent = text.Element.GetComponent<Text>(); }
public MyList(Sprite sprite, Rect rect) : base("List") { Element = new MyPanel(sprite, rect).Element; Element.AddComponent<Mask>(); var scrollRect = Element.AddComponent<ScrollRect>(); var panelIn = new MyPanel(sprite, new Rect(0, 0, 0, 200)); var panelInRect = panelIn.Element.GetComponent<RectTransform>(); panelInRect.pivot = new Vector2(0.5f, 1); panelIn.SetAnchor(new Vector2(0, 0), new Vector2(1, 1)); panelIn.Element.AddComponent<VerticalLayoutGroup>(); AddElement(panelIn); MainElement = panelIn; scrollRect.content = MainElement.Element.GetComponent<RectTransform>(); }