예제 #1
0
        public IEnumerator Test()
        {
            var dependencies = new DependencyContainer();

            dependencies.CacheAs <IDependencyContainer>(dependencies);
            dependencies.CacheAs <IAtlas <Sprite> >(new ResourceSpriteAtlas());

            var env  = GraphicTestEnvironment.Create();
            var root = env.CreateRoot(dependencies);

            var font = env.ArialFont.ToFont();

            var dropdown = root.CreateChild <UguiDropdown>("dropdown");

            for (int i = 0; i < 10; i++)
            {
                dropdown.Options.Add(new Dropdown.OptionData($"Option {i}"));
            }
            dropdown.Label.Font  = font;
            dropdown.Label.Color = Color.black;

            dropdown.Property.Font = font;
            dropdown.Property.PopupBackground.Color = new Color(0f, 0f, 0f, 0.6f);
            dropdown.Property.LabelColor            = new Color(1f, 1f, 1f, 0.8f);
            dropdown.Property.SelectedColor         = new Color(1f, 1f, 1f, 1f);
            dropdown.Property.EntryHeight           = 30f;

            dropdown.Value = 5;

            while (env.IsRunning)
            {
                yield return(null);
            }
        }
        public IEnumerator Test()
        {
            var dependencies = new DependencyContainer();

            dependencies.CacheAs <IDependencyContainer>(dependencies);
            dependencies.CacheAs <IAtlas <Sprite> >(new ResourceSpriteAtlas());

            var env  = GraphicTestEnvironment.Create();
            var root = env.CreateRoot(dependencies);

            var toggle = root.CreateChild <UguiToggle>("toggle");

            toggle.Background.SpriteName = "circle-32";
            toggle.Tick.SpriteName       = "circle-16";
            toggle.Tick.Color            = Color.black;
            toggle.Tick.Size             = new Vector2(16, 16);

            while (env.IsRunning)
            {
                if (Input.GetKeyDown(KeyCode.Q))
                {
                    toggle.UseFade = !toggle.UseFade;
                }
                if (Input.GetKeyDown(KeyCode.W))
                {
                    toggle.Value = !toggle.Value;
                }
                yield return(null);
            }
        }
        public IEnumerator Test()
        {
            var dependencies = new DependencyContainer();

            dependencies.CacheAs <IDependencyContainer>(dependencies);
            dependencies.CacheAs <IAtlas <Sprite> >(new ResourceSpriteAtlas());

            var env  = GraphicTestEnvironment.Create();
            var root = env.CreateRoot(dependencies);

            var button = root.CreateChild <UguiButton>("button");

            button.Label.Font       = env.ArialFont.ToFont();
            button.Background.Color = Color.green;

            button.Label.Text = "Press me!";

            int clickCount = 0;

            button.OnClick += () =>
            {
                clickCount++;
                Debug.Log("Clicked");
            };
            Assert.AreEqual(0, clickCount);

            button.InvokeClick();
            Assert.AreEqual(1, clickCount);

            while (env.IsRunning)
            {
                yield return(null);
            }
        }
예제 #4
0
        public IEnumerator Test()
        {
            var dependencies = new DependencyContainer();

            dependencies.CacheAs <IDependencyContainer>(dependencies);
            dependencies.CacheAs <IAtlas <Sprite> >(new ResourceSpriteAtlas());

            var env  = GraphicTestEnvironment.Create();
            var root = env.CreateRoot(dependencies);

            var slider = root.CreateChild <UguiSlider>("slider");

            slider.Background.SpriteName = "circle-16";
            slider.Background.Color      = Color.black;

            slider.Foreground.SpriteName = "circle-16";
            slider.Foreground.Color      = Color.green;

            slider.Thumb.SpriteName = "circle-32";
            slider.Thumb.Size       = new Vector2(48f, 48f);

            while (env.IsRunning)
            {
                if (Input.GetKeyDown(KeyCode.Q))
                {
                    slider.Direction = Slider.Direction.LeftToRight;
                }
                if (Input.GetKeyDown(KeyCode.W))
                {
                    slider.Direction = Slider.Direction.TopToBottom;
                }
                if (Input.GetKeyDown(KeyCode.E))
                {
                    slider.Direction = Slider.Direction.RightToLeft;
                }
                if (Input.GetKeyDown(KeyCode.R))
                {
                    slider.Direction = Slider.Direction.BottomToTop;
                }

                if (Input.GetKeyDown(KeyCode.A))
                {
                    slider.Value = 0f;
                }
                if (Input.GetKeyDown(KeyCode.S))
                {
                    slider.Value = 0.5f;
                }
                if (Input.GetKeyDown(KeyCode.D))
                {
                    slider.Value = 1f;
                }

                yield return(null);
            }
        }
        public IEnumerator Test()
        {
            var env  = GraphicTestEnvironment.Create();
            var root = env.CreateRoot(null);

            var obj1 = root.CreateChild <UguiSprite>("1", 0);
            {
                obj1.Alpha    = 0.5f;
                obj1.Position = new Vector2(-50f, 50f);
            }
            var obj2 = root.CreateChild <UguiSprite>("2", 1);
            {
                obj2.Alpha    = 0.5f;
                obj2.Position = new Vector2(0f, 00f);
            }
            var obj3 = root.CreateChild <UguiSprite>("3", 2);
            {
                obj3.Alpha    = 0.5f;
                obj3.Position = new Vector2(20f, 25f);
            }

            var effects = new DefaultShaderEffect[] {
                obj1.AddEffect(new DefaultShaderEffect()),
                obj2.AddEffect(new DefaultShaderEffect()),
                obj3.AddEffect(new DefaultShaderEffect()),
            };

            while (env.IsRunning)
            {
                if (Input.GetKeyDown(KeyCode.Alpha1))
                {
                    effects.ForEach(e =>
                    {
                        e.StencilOperation = StencilOp.IncrementSaturate;
                        e.CompareFunction  = CompareFunction.Equal;
                        Debug.Log("Changed op: " + e.StencilOperation + ", comp : " + e.CompareFunction);
                    });
                }

                if (Input.GetKeyDown(KeyCode.Q))
                {
                    effects.ForEach(e =>
                    {
                        e.StencilOperation = StencilOp.Keep;
                        e.CompareFunction  = CompareFunction.Always;
                    });
                }
                yield return(null);
            }
        }
        public IEnumerator Test()
        {
            var dependencies = new DependencyContainer();
            var atlas        = new ResourceSpriteAtlas();

            dependencies.CacheAs <IDependencyContainer>(dependencies);
            dependencies.CacheAs <IAtlas <Sprite> >(atlas);

            var env  = GraphicTestEnvironment.Create();
            var root = env.CreateRoot(dependencies);

            var sprite = root.CreateChild <UguiSprite>("sprite");

            sprite.SpriteName = "circle-32";

            Assert.AreEqual(atlas, sprite.Atlas);

            while (env.IsRunning)
            {
                if (Input.GetKeyDown(KeyCode.Alpha1))
                {
                    sprite.ImageType = Image.Type.Simple;
                }
                else if (Input.GetKeyDown(KeyCode.Alpha2))
                {
                    sprite.ImageType = Image.Type.Sliced;
                }
                else if (Input.GetKeyDown(KeyCode.Alpha3))
                {
                    sprite.ImageType = Image.Type.Tiled;
                }

                if (Input.GetKeyDown(KeyCode.Equals))
                {
                    sprite.Height = sprite.Width += 10;
                }
                else if (Input.GetKeyDown(KeyCode.Minus))
                {
                    sprite.Height = sprite.Width -= 10;
                }
                else if (Input.GetKeyDown(KeyCode.Alpha0))
                {
                    sprite.ResetSize();
                }
                yield return(null);
            }
        }
예제 #7
0
        public IEnumerator Test()
        {
            // Load test texture
            TextureRequest req      = new TextureRequest(Path.Combine(TestConstants.TestAssetPath, "Graphics/UI/texture0.jpg"));//0.jpg"));
            var            listener = new TaskListener <IWebRequest>();

            req.Request(listener);
            while (!req.IsFinished)
            {
                yield return(null);
            }

            Assert.IsNotNull(listener.Value);
            Assert.IsNotNull(listener.Value.Response);

            var loadedTexture = listener.Value.Response.TextureData;

            Assert.IsNotNull(loadedTexture);

            var env  = GraphicTestEnvironment.Create();
            var root = env.CreateRoot(null);

            var texture = root.CreateChild <UguiTexture>("texture");

            texture.Texture = loadedTexture;
            texture.Width   = 400;
            texture.Height  = 400;
            texture.FillTexture();

            while (env.IsRunning)
            {
                if (Input.GetKeyDown(KeyCode.Minus))
                {
                    texture.Width  -= 100;
                    texture.Height += 100;
                    texture.FillTexture();
                }
                else if (Input.GetKeyDown(KeyCode.Equals))
                {
                    texture.Width  += 100;
                    texture.Height -= 100;
                    texture.FillTexture();
                }
                yield return(null);
            }
        }
        public void Test()
        {
            var env  = GraphicTestEnvironment.Create();
            var root = env.CreateRoot(null);

            var  eventTrigger = root.CreateChild <UguiObject>("lol").AddComponentInject <EventTrigger>();
            bool eventCalled  = false;
            var  entry        = new EventTrigger.Entry()
            {
                eventID  = EventTriggerType.PointerClick,
                callback = new EventTrigger.TriggerEvent()
            };

            entry.callback.AddListener(delegate { eventCalled = true; });
            eventTrigger.triggers.Add(entry);

            eventTrigger.OnPointerClick(null);
            Assert.IsTrue(eventCalled);
        }
        public IEnumerator TestWithInputManager()
        {
            var inputManager = InputManager.Create(new Vector2(1280f, 720f));

            var dependencies = new DependencyContainer();

            dependencies.CacheAs <IDependencyContainer>(dependencies);
            dependencies.CacheAs <IInputManager>(inputManager);
            dependencies.CacheAs <IAtlas <Sprite> >(new ResourceSpriteAtlas());

            var env  = GraphicTestEnvironment.Create();
            var root = env.CreateRoot(dependencies);

            var camera = root.Cam;

            var trigger = root.CreateChild <UguiTrigger>("toggle");
            var bg      = trigger.CreateChild <UguiSprite>("bg");
            {
                bg.Anchor = AnchorType.Fill;
                bg.Offset = Offset.Zero;
            }

            var pointerEvent             = new PointerEventData(EventSystem.current);
            List <RaycastResult> results = new List <RaycastResult>();

            while (env.IsRunning)
            {
                var mouse = inputManager.GetMouse(0);
                pointerEvent.position = mouse.RawPosition;
                Debug.Log("Mouse pos: " + pointerEvent.position);

                root.Raycaster.Raycast(pointerEvent, results);
                foreach (var result in results)
                {
                    Debug.LogWarning("--------------");
                    Debug.Log("Local pos: " + trigger.transform.InverseTransformPoint(result.worldPosition));
                }

                results.Clear();
                yield return(null);
            }
        }
예제 #10
0
        public IEnumerator Test()
        {
            var env  = GraphicTestEnvironment.Create();
            var root = env.CreateRoot(null);

            var fontInfo = SystemFontProvider.Fonts.Where(f => f.Name.Equals("Arial", StringComparison.OrdinalIgnoreCase)).FirstOrDefault();

            Assert.IsNotNull(fontInfo);
            var font = new SystemFont(fontInfo);

            Assert.IsNotNull(font.Normal);

            var label = root.CreateChild <UguiLabel>("label");

            label.Font = font;
            label.Text = "This is my test text!";

            while (env.IsRunning)
            {
                DoUpdateTest(label);
                yield return(null);
            }
        }
        public IEnumerator Test()
        {
            var dependencies = new DependencyContainer();

            dependencies.CacheAs <IDependencyContainer>(dependencies);
            dependencies.CacheAs <IAtlas <Sprite> >(new ResourceSpriteAtlas());

            var env  = GraphicTestEnvironment.Create();
            var root = env.CreateRoot(dependencies);

            var inputBox = root.CreateChild <UguiInputBox>("inputBox");

            Assert.IsNotNull(inputBox.PlaceholderLabel);
            Assert.IsNotNull(inputBox.ValueLabel);
            Assert.IsNotNull(inputBox.Background);

            inputBox.OnChanged += (value) =>
            {
                Assert.AreEqual(value, inputBox.Text);
                Debug.Log("OnChanged: " + value);
            };
            inputBox.OnSubmitted += (value) =>
            {
                Assert.AreEqual(value, inputBox.Text);
                Debug.Log("OnSubmitted: " + value);
            };

            inputBox.Font             = env.ArialFont.ToFont();
            inputBox.Background.Color = Color.black;

            while (env.IsRunning)
            {
                UguiLabelTest.DoUpdateTest(inputBox, KeyCode.LeftShift);
                DoUpdateTest(inputBox, KeyCode.LeftControl);
                yield return(null);
            }
        }
예제 #12
0
        public IEnumerator Test()
        {
            var dependencies = new DependencyContainer();

            dependencies.CacheAs <IDependencyContainer>(dependencies);
            dependencies.CacheAs <IAtlas <Sprite> >(new ResourceSpriteAtlas());

            var env  = GraphicTestEnvironment.Create();
            var root = env.CreateRoot(dependencies);

            var sprite = root.CreateChild <UguiSprite>("sprite");

            sprite.Size = new Vector2(20f, 20f);

            var anime = new Anime();

            anime.AnimateFloat(value => sprite.X = value)
            .AddTime(0f, 0f, Utils.EaseType.QuadEaseOut)
            .AddTime(1f, 200f, Utils.EaseType.Linear)
            .AddTime(2f, 200f, Utils.EaseType.QuadEaseOut)
            .AddTime(3f, 400f)
            .Build();
            Assert.AreEqual(3f, anime.Duration, Delta);

            anime.AddEvent(0f, () => Debug.Log("Event 0"));
            anime.AddEvent(1f, () => Debug.Log("Event 1"));
            anime.AddEvent(2f, () => Debug.Log("Event 2"));
            anime.AddEvent(3f, () => Debug.Log("Event 3"));
            anime.AddEvent(4f, () => Debug.Log("Event 4"));
            Assert.AreEqual(4f, anime.Duration, Delta);

            while (env.IsRunning)
            {
                if (Input.GetKeyDown(KeyCode.Q))
                {
                    anime.Play();
                    Assert.IsTrue(anime.IsPlaying);
                }
                if (Input.GetKeyDown(KeyCode.W))
                {
                    anime.PlayFromStart();
                    Assert.IsTrue(anime.IsPlaying);
                }
                if (Input.GetKeyDown(KeyCode.E))
                {
                    anime.Pause();
                    Assert.IsFalse(anime.IsPlaying);
                }
                if (Input.GetKeyDown(KeyCode.R))
                {
                    anime.Stop();
                    Assert.IsFalse(anime.IsPlaying);
                }

                if (Input.GetKeyDown(KeyCode.BackQuote))
                {
                    anime.Seek(0f);
                    Assert.AreEqual(0f, anime.Time, Delta);
                }
                if (Input.GetKeyDown(KeyCode.Alpha1))
                {
                    anime.Seek(1f);
                    Assert.AreEqual(1f, anime.Time, Delta);
                }
                if (Input.GetKeyDown(KeyCode.Alpha2))
                {
                    anime.Seek(2f);
                    Assert.AreEqual(2f, anime.Time, Delta);
                }
                if (Input.GetKeyDown(KeyCode.Alpha3))
                {
                    anime.Seek(3f);
                    Assert.AreEqual(3f, anime.Time, Delta);
                }
                if (Input.GetKeyDown(KeyCode.Alpha4))
                {
                    anime.Seek(4f);
                    Assert.AreEqual(4f, anime.Time, Delta);
                }

                if (Input.GetKeyDown(KeyCode.Equals))
                {
                    anime.Speed += 0.25f;
                }
                else if (Input.GetKeyDown(KeyCode.Minus))
                {
                    anime.Speed -= 0.25f;
                }

                if (Input.GetKeyDown(KeyCode.A))
                {
                    anime.WrapMode = WrapModeType.None;
                    Debug.Log("Wrapmode set to none");
                }
                if (Input.GetKeyDown(KeyCode.S))
                {
                    anime.WrapMode = WrapModeType.Reset;
                    Debug.Log("Wrapmode set to reset");
                }
                if (Input.GetKeyDown(KeyCode.D))
                {
                    anime.WrapMode = WrapModeType.Loop;
                    Debug.Log("Wrapmode set to loop");
                }

                if (Input.GetKeyDown(KeyCode.F))
                {
                    anime.StopMode = StopModeType.None;
                    Debug.Log("Stopmode set to none");
                }
                if (Input.GetKeyDown(KeyCode.G))
                {
                    anime.StopMode = StopModeType.Reset;
                    Debug.Log("Stopmode set to reset");
                }
                if (Input.GetKeyDown(KeyCode.H))
                {
                    anime.StopMode = StopModeType.End;
                    Debug.Log("Stopmode set to end");
                }
                yield return(null);
            }
        }
예제 #13
0
        public IEnumerator TestUgui()
        {
            var inputManager = InputManager.Create(new Vector2(1280f, 720f));
            var dependency   = new DependencyContainer(true);

            dependency.CacheAs <IInputManager>(inputManager);

            var receivers = new DummyUguiObject[9];

            Action <int> assertReceivedUntil = (int lastReceivedIndex) =>
            {
                for (int i = 0; i < receivers.Length; i++)
                {
                    if (i <= lastReceivedIndex)
                    {
                        Assert.IsTrue(receivers[i].DidUpdate);
                    }
                    else
                    {
                        Assert.IsFalse(receivers[i].DidUpdate);
                    }
                }
            };

            var env  = GraphicTestEnvironment.Create();
            var root = env.CreateRoot(dependency);

            {
                var base0 = root.CreateChild <DummyUguiObject>("base0", 0);
                {
                    base0.SetReceiveInputs(true);
                    receivers[8] = base0;
                }
                var base1 = root.CreateChild <DummyUguiObject>("base1", 1);
                {
                    base1.Canvas = base1.RawObject.AddComponent <Canvas>();
                    base1.Canvas.overrideSorting = true;
                    base1.Canvas.sortingOrder    = 1;
                    base1.SetReceiveInputs(true);
                    receivers[1] = base1;

                    var obj0 = base1.CreateChild <DummyUguiObject>("obj0", 0);
                    {
                        obj0.SetReceiveInputs(true);
                        receivers[0] = obj0;
                    }
                }
                var base2 = root.CreateChild <DummyUguiObject>("base2", 4);
                {
                    base2.SetReceiveInputs(true);
                    receivers[7] = base2;

                    var obj0 = base2.CreateChild <DummyUguiObject>("obj0", 1);
                    {
                        obj0.SetReceiveInputs(true);
                        receivers[6] = obj0;

                        var obj00 = obj0.CreateChild <DummyUguiObject>("obj00", 0);
                        {
                            obj00.SetReceiveInputs(true);
                            receivers[5] = obj00;
                        }
                    }
                    var obj1 = base2.CreateChild <DummyUguiObject>("obj1", 2);
                    {
                        obj1.SetReceiveInputs(true);
                        receivers[4] = obj1;
                    }
                }
                var base3 = root.CreateChild <DummyUguiObject>("base3", 5);
                {
                    base3.SetReceiveInputs(true);
                    receivers[3] = base3;

                    var obj0 = base3.CreateChild <DummyUguiObject>("obj0", 100);
                    {
                        obj0.SetReceiveInputs(true);
                        receivers[2] = obj0;
                    }
                }
            }

            assertReceivedUntil(-1);
            for (int i = 0; i < receivers.Length; i++)
            {
                yield return(null);

                Debug.Log("checking index: " + i);
                assertReceivedUntil(i);
                receivers[i].SetReceiveInputs(false);
            }
        }
        public IEnumerator Test()
        {
            var dependencies = new DependencyContainer();

            dependencies.CacheAs <IDependencyContainer>(dependencies);
            dependencies.CacheAs <IAtlas <Sprite> >(new ResourceSpriteAtlas());

            var env  = GraphicTestEnvironment.Create();
            var root = env.CreateRoot(dependencies);

            var scrollbar = root.CreateChild <UguiScrollBar>("scrollbar");

            scrollbar.Foreground.SpriteName = "circle-16";
            scrollbar.Background.SpriteName = "circle-16";
            scrollbar.Background.Color      = new Color(0.125f, 0.125f, 0.125f);

            while (env.IsRunning)
            {
                if (Input.GetKeyDown(KeyCode.Q))
                {
                    scrollbar.Direction = Scrollbar.Direction.LeftToRight;
                }
                if (Input.GetKeyDown(KeyCode.W))
                {
                    scrollbar.Direction = Scrollbar.Direction.TopToBottom;
                }
                if (Input.GetKeyDown(KeyCode.E))
                {
                    scrollbar.Direction = Scrollbar.Direction.RightToLeft;
                }
                if (Input.GetKeyDown(KeyCode.R))
                {
                    scrollbar.Direction = Scrollbar.Direction.BottomToTop;
                }

                if (Input.GetKeyDown(KeyCode.A))
                {
                    scrollbar.Value = 0f;
                }
                if (Input.GetKeyDown(KeyCode.S))
                {
                    scrollbar.Value = 0.5f;
                }
                if (Input.GetKeyDown(KeyCode.D))
                {
                    scrollbar.Value = 1f;
                }

                if (Input.GetKeyDown(KeyCode.F))
                {
                    scrollbar.ForegroundSize = 0f;
                }
                if (Input.GetKeyDown(KeyCode.G))
                {
                    scrollbar.ForegroundSize = 0.25f;
                }
                if (Input.GetKeyDown(KeyCode.H))
                {
                    scrollbar.ForegroundSize = 0.5f;
                }

                if (Input.GetKeyDown(KeyCode.J))
                {
                    scrollbar.Steps = 0;
                }
                if (Input.GetKeyDown(KeyCode.K))
                {
                    scrollbar.Steps = 5;
                }
                if (Input.GetKeyDown(KeyCode.L))
                {
                    scrollbar.Steps = 10;
                }
                yield return(null);
            }
        }
        public IEnumerator Test()
        {
            var dependencies = new DependencyContainer();

            dependencies.CacheAs <IDependencyContainer>(dependencies);
            dependencies.CacheAs <IAtlas <Sprite> >(new ResourceSpriteAtlas());

            var env  = GraphicTestEnvironment.Create();
            var root = env.CreateRoot(dependencies);

            font = env.ArialFont.ToFont();

            var listView = root.CreateChild <UguiListView>("listview");

            listViewContainer         = listView.Container;
            listView.Background.Color = new Color();

            // Setup properties
            listView.Limit = 0;
            Assert.AreEqual(1, listView.Limit);
            listView.CellSize = new Vector2(150f, 30f);
            listView.Size     = new Vector2(600f, 600f);

            listView.Initialize(OnCreateItem, OnUpdateItem);

            while (env.IsRunning)
            {
                if (Input.GetKeyDown(KeyCode.Equals))
                {
                    listView.TotalItems += 5;
                }
                else if (Input.GetKeyDown(KeyCode.Minus))
                {
                    listView.TotalItems -= 5;
                }

                if (Input.GetKeyDown(KeyCode.Q))
                {
                    listView.ForceUpdate();
                }
                if (Input.GetKeyDown(KeyCode.W))
                {
                    listView.Recalibrate();
                }

                if (Input.GetKeyDown(KeyCode.A))
                {
                    listView.CellWidth += 10;
                }
                else if (Input.GetKeyDown(KeyCode.S))
                {
                    listView.CellWidth -= 10;
                }

                if (Input.GetKeyDown(KeyCode.D))
                {
                    listView.CellHeight += 10;
                }
                else if (Input.GetKeyDown(KeyCode.F))
                {
                    listView.CellHeight -= 10;
                }

                if (Input.GetKeyDown(KeyCode.Z))
                {
                    listView.Corner = GridLayoutGroup.Corner.UpperLeft;
                }
                if (Input.GetKeyDown(KeyCode.X))
                {
                    listView.Corner = GridLayoutGroup.Corner.UpperRight;
                }
                if (Input.GetKeyDown(KeyCode.C))
                {
                    listView.Corner = GridLayoutGroup.Corner.LowerLeft;
                }
                if (Input.GetKeyDown(KeyCode.V))
                {
                    listView.Corner = GridLayoutGroup.Corner.LowerRight;
                }

                if (Input.GetKeyDown(KeyCode.B))
                {
                    listView.Axis = GridLayoutGroup.Axis.Horizontal;
                }
                if (Input.GetKeyDown(KeyCode.N))
                {
                    listView.Axis = GridLayoutGroup.Axis.Vertical;
                }

                if (Input.GetKeyDown(KeyCode.O))
                {
                    listView.Limit++;
                }
                if (Input.GetKeyDown(KeyCode.P))
                {
                    listView.Limit--;
                }

                if (Input.GetKeyDown(KeyCode.K))
                {
                    Debug.Log("Container start pos: " + listView.ContainerStartPos);
                }
                if (Input.GetKeyDown(KeyCode.L))
                {
                    Debug.Log("Container end pos: " + listView.ContainerEndPos);
                }

                yield return(null);
            }
        }
        public IEnumerator Test()
        {
            var dependencies = new DependencyContainer();

            dependencies.CacheAs <IDependencyContainer>(dependencies);
            dependencies.CacheAs <IAtlas <Sprite> >(new ResourceSpriteAtlas());

            var env  = GraphicTestEnvironment.Create();
            var root = env.CreateRoot(dependencies);

            var scrollview = root.CreateChild <UguiScrollView>("scrollview");

            var horizontalScrollbar = root.CreateChild <UguiScrollBar>("horizontal-bar", 1);
            var verticalScrollbar   = root.CreateChild <UguiScrollBar>("vertical-bar", 2);

            scrollview.Size                = new Vector2(300, 600);
            scrollview.Container.Size      = new Vector2(500, 900);
            scrollview.Background.Alpha    = 0.25f;
            scrollview.HorizontalScrollbar = horizontalScrollbar;
            scrollview.VerticalScrollbar   = verticalScrollbar;

            horizontalScrollbar.Position         = new Vector2(0f, -302f);
            horizontalScrollbar.Size             = new Vector2(300f, 4f);
            horizontalScrollbar.Background.Color = Color.grey;

            verticalScrollbar.Position         = new Vector2(152f, 0f);
            verticalScrollbar.Direction        = Scrollbar.Direction.BottomToTop;
            verticalScrollbar.Size             = new Vector2(4f, 600f);
            verticalScrollbar.Background.Color = Color.grey;

            while (env.IsRunning)
            {
                if (Input.GetKeyDown(KeyCode.Q))
                {
                    scrollview.IsHorizontal = !scrollview.IsHorizontal;
                }
                if (Input.GetKeyDown(KeyCode.W))
                {
                    scrollview.IsVertical = !scrollview.IsVertical;
                }

                if (Input.GetKeyDown(KeyCode.E))
                {
                    scrollview.Movement++;
                    if (scrollview.Movement > ScrollRect.MovementType.Clamped)
                    {
                        scrollview.Movement = 0;
                    }
                }

                if (Input.GetKeyDown(KeyCode.R))
                {
                    scrollview.Alpha = 1f;
                }
                if (Input.GetKeyDown(KeyCode.T))
                {
                    scrollview.Alpha = 0.5f;
                }
                if (Input.GetKeyDown(KeyCode.Y))
                {
                    scrollview.Alpha = 0f;
                }

                if (Input.GetKeyDown(KeyCode.U))
                {
                    scrollview.UseMask = !scrollview.UseMask;
                }
                if (Input.GetKeyDown(KeyCode.I))
                {
                    scrollview.ShowMaskingSprite = !scrollview.ShowMaskingSprite;
                }

                if (Input.GetKeyDown(KeyCode.Z))
                {
                    scrollview.ScrollTo(Vector2.zero);
                }
                if (Input.GetKeyDown(KeyCode.X))
                {
                    scrollview.ScrollTo(new Vector2(-100, 150));
                }
                if (Input.GetKeyDown(KeyCode.C))
                {
                    scrollview.ScrollTo(new Vector2(-200, 300));
                }

                yield return(null);
            }
        }