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; }
public VideoComponent(UGUIContext context) : base(context, "video") { VideoPlayer = AddComponent <VideoPlayer>(); VideoPlayer.renderMode = VideoRenderMode.RenderTexture; VideoPlayer.targetTexture = RenderTexture; VideoPlayer.prepareCompleted += PrepareCompleted; }
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 }
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; }
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); }
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); }
public AnchorComponent(UGUIContext context) : base(context, "anchor") { clickHandler = AddComponent <AnchorClickHandler>(); clickHandler.OnEvent += OnClick; }
public ContainerComponent(UGUIContext context, string tag) : base(context, tag) { Container = RectTransform; }
protected ContainerComponent(RectTransform existing, UGUIContext context) : base(existing, context) { Container = existing; }
public RawImageComponent(UGUIContext context, string tag = "rawimage") : base(context, tag) { Image = ImageContainer.AddComponent <RawImage>(); Measurer.Texture = Image.texture; }
public ImageComponent(UGUIContext context, string tag = "image") : base(context, tag) { Image = ImageContainer.AddComponent <Image>(); Measurer.Sprite = Image.sprite; }
public ButtonComponent(UGUIContext context) : base(context, "button") { Button = AddComponent <Button>(); }
public ObjectComponent(UGUIContext context) : base(context, "object") { }
public RenderComponent(UGUIContext context) : base(context, "render") { }