Example #1
0
        public ScrollComponent(UGUIContext Context) : base(Context, "scroll")
        {
            ScrollRect = AddComponent <ScrollRect>();

            var viewport = new GameObject("[Scroll Viewport]").AddComponent <RectTransform>();

            viewport.gameObject.AddComponent <RectMask2D>();
            viewport.SetParent(RectTransform, false);

            viewport.anchorMin = Vector2.zero;
            viewport.anchorMax = Vector2.one;
            viewport.sizeDelta = Vector2.zero;
            viewport.pivot     = Vector2.up;

            var content = new GameObject("[Scroll Container]").AddComponent <RectTransform>();

            Container = content;
            content.SetParent(viewport, false);

            content.anchorMin = Vector2.zero;
            content.anchorMax = Vector2.one;
            content.pivot     = Vector2.up;
            content.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, 0);
            content.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 0);
            content.gameObject.AddComponent <CalculateSizeFromContents>().Layout = Layout;

            ScrollRect.horizontalScrollbar           = CreateScrollbar(false, viewport);
            ScrollRect.verticalScrollbar             = CreateScrollbar(true, viewport);
            ScrollRect.viewport                      = viewport;
            ScrollRect.content                       = content;
            ScrollRect.scrollSensitivity             = 50;
            ScrollRect.horizontalScrollbarVisibility = ScrollRect.ScrollbarVisibility.AutoHide;
            ScrollRect.verticalScrollbarVisibility   = ScrollRect.ScrollbarVisibility.AutoHide;
            ScrollRect.movementType                  = ScrollRect.MovementType.Clamped;
        }
Example #2
0
        public VideoComponent(UGUIContext context) : base(context, "video")
        {
            VideoPlayer               = AddComponent <VideoPlayer>();
            VideoPlayer.renderMode    = VideoRenderMode.RenderTexture;
            VideoPlayer.targetTexture = RenderTexture;

            VideoPlayer.prepareCompleted += PrepareCompleted;
        }
Example #3
0
        public SvgComponent(UGUIContext context, string tag = "svg") : base(context, tag)
        {
#if REACT_VECTOR_GRAPHICS
            Image           = ImageContainer.AddComponent <Unity.VectorGraphics.SVGImage>();
            Measurer.Sprite = Image.sprite;
#else
            Debug.LogWarning("Unity.VectorGraphics module is required to use SVG components");
#endif
        }
Example #4
0
        public HostComponent(RectTransform host, UGUIContext context) : base(host, context)
        {
            Tag           = "_root";
            Layout.Width  = Width;
            Layout.Height = Height;

            var responsive = GetOrAddComponent <ResponsiveElement>();

            responsive.Layout  = Layout;
            responsive.Context = context;
        }
Example #5
0
        public BaseImageComponent(UGUIContext context, string tag) : base(context, tag)
        {
            ImageContainer = new ContainerComponent(context, "");
            ImageContainer.GameObject.name = "[ImageContent]";

            Measurer         = ImageContainer.AddComponent <ImageMeasurer>();
            Measurer.Context = context;
            Measurer.Layout  = ImageContainer.Layout;
            ImageContainer.Layout.SetMeasureFunction(Measurer.Measure);

            ImageContainer.SetParent(this);
        }
Example #6
0
        public TextComponent(string text, UGUIContext context, string tag) : base(context, tag)
        {
            GameObject.name = "TEXT";
            Text            = AddComponent <TextMeshProUGUI>();

            Measurer         = AddComponent <TextMeasurer>();
            Measurer.Layout  = Layout;
            Measurer.Context = context;
            Layout.SetMeasureFunction(Measurer.Measure);

            if (text != null)
            {
                SetText(text);
            }
        }
 public BaseRenderTextureComponent(UGUIContext context, string tag) : base(context, tag)
 {
     RenderTexture = new RenderTexture(1, 1, 1);
     SetTexture(RenderTexture);
 }
Example #8
0
 public AnchorComponent(UGUIContext context) : base(context, "anchor")
 {
     clickHandler          = AddComponent <AnchorClickHandler>();
     clickHandler.OnEvent += OnClick;
 }
Example #9
0
 public ContainerComponent(UGUIContext context, string tag) : base(context, tag)
 {
     Container = RectTransform;
 }
Example #10
0
 protected ContainerComponent(RectTransform existing, UGUIContext context) : base(existing, context)
 {
     Container = existing;
 }
Example #11
0
 public RawImageComponent(UGUIContext context, string tag = "rawimage") : base(context, tag)
 {
     Image            = ImageContainer.AddComponent <RawImage>();
     Measurer.Texture = Image.texture;
 }
Example #12
0
 public ImageComponent(UGUIContext context, string tag = "image") : base(context, tag)
 {
     Image           = ImageContainer.AddComponent <Image>();
     Measurer.Sprite = Image.sprite;
 }
Example #13
0
 public ButtonComponent(UGUIContext context) : base(context, "button")
 {
     Button = AddComponent <Button>();
 }
Example #14
0
 public ObjectComponent(UGUIContext context) : base(context, "object")
 {
 }
Example #15
0
 public RenderComponent(UGUIContext context) : base(context, "render")
 {
 }