예제 #1
0
        public (IComponent[], IAsset[]) Render(XdObjectJson xdObject, Obb obb, XdAssetHolder assetHolder)
        {
            var(imageComponent, assets) = ShapeObjectParser.RenderImage(xdObject, obb, assetHolder);

            IComponent scrollbar = new VerticalScrollbarComponent(imageComponent);

            if (xdObject.HasParameter("horizontal"))
            {
                scrollbar = new HorizontalScrollbarComponent(imageComponent);
            }
            return(new[] { scrollbar }, assets);
        }
예제 #2
0
        private static Component CreateHorizontalScrollbar(GameObject gameObject, IAssetLoader assetLoader, HorizontalScrollbarComponent horizontalScrollbarComponent)
        {
            var scrollbar = gameObject.AddComponent <Scrollbar>();

            scrollbar.transition = Selectable.Transition.None;
            scrollbar.direction  = Scrollbar.Direction.RightToLeft;

            if (scrollbar.handleRect == null)
            {
                var handle     = new GameObject("Handle");
                var handleRect = handle.AddComponent <RectTransform>();
                handleRect.SetParent(gameObject.transform);
                handleRect.anchorMin        = Vector2.zero;
                handleRect.anchorMax        = Vector2.one;
                handleRect.anchoredPosition = Vector2.zero;
                handleRect.sizeDelta        = Vector2.zero;
                scrollbar.handleRect        = handleRect;

                handle.AddComponent <Image>();
            }

            if (horizontalScrollbarComponent.Image != null)
            {
                var image = scrollbar.handleRect.GetComponent <Image>();
                UpdateImage(gameObject, image, horizontalScrollbarComponent.Image, assetLoader);
            }

            return(scrollbar);
        }