예제 #1
0
        protected static T createBaseWidget <T>(LayoutElementData element) where T : TUIWidget
        {
            GameObject obj = new GameObject("TUIWidget");

            obj.layer |= LayerMask.NameToLayer("UI");

            if (element != null)
            {
                LayoutElement layoutElement = obj.AddComponent <LayoutElement>();
                element.Set(ref layoutElement);
            }

            obj.AddComponent <EventTrigger>();
            obj.AddComponent <RectTransform>();

            T widget = obj.AddComponent <T>();

            widget.Anchor   = AnchorType.TopLeft;
            widget.Position = Vector2.zero;
            widget.Pivot    = new Vector2(0, 1);

            return(widget);
        }
예제 #2
0
 public static TUIWidget Create(LayoutElementData element = null)
 {
     return(createBaseWidget <TUIWidget>(element));
 }