コード例 #1
0
        private void Init(PrepareScreen prepareScreen)
        {
            gradient = CreateChild <UguiSprite>("gradient", 0);
            {
                gradient.Anchor     = AnchorType.Fill;
                gradient.RawSize    = Vector2.zero;
                gradient.SpriteName = "gradation-top";
                gradient.Color      = new Color(0f, 0f, 0f, 0.75f);
            }
            listContainer = CreateChild <UguiObject>("list-container", 1);
            {
                listContainer.Anchor   = AnchorType.TopStretch;
                listContainer.Pivot    = PivotType.Top;
                listContainer.RawWidth = 0f;
                listContainer.Height   = 64f;
                listContainer.Y        = -prepareScreen.MenuBarHeight;

                versionList = listContainer.CreateChild <UguiListView>("version-list", 0);
                {
                    versionList.Anchor  = AnchorType.Fill;
                    versionList.RawSize = new Vector2(-64f, 0f);
                    versionList.SetOffsetVertical(0f);

                    versionList.Background.Alpha = 0f;
                    versionList.UseMask          = false;
                    versionList.IsVertical       = false;

                    versionList.Initialize(CreateVersionCell, SetupVersionCell);
                    versionList.Axis     = GridLayoutGroup.Axis.Horizontal;
                    versionList.CellSize = new Vector2(64f, 64f);
                }
            }

            // Call after a frame due to unity ui limitations.
            InvokeAfterFrames(1, OnEnableInited);
        }
コード例 #2
0
        private void Init()
        {
            // Make the menu fit within the parent's object.
            Anchor = AnchorType.Fill;
            Offset = Offset.Zero;

            var blocker = CreateChild <Blocker>("blocker", 0);

            {
                blocker.OnTriggered += CloseMenu;
            }
            holder = CreateChild("holder", 1);
            {
                holder.Size = new Vector2(ContainerWidth, 0f);

                aniHolder = holder.CreateChild("ani-holder", 0);
                {
                    aniHolder.Anchor = AnchorType.Fill;
                    aniHolder.Offset = Offset.Zero;

                    canvasGroup       = aniHolder.RawObject.AddComponent <CanvasGroup>();
                    canvasGroup.alpha = 0f;

                    shadow = aniHolder.CreateChild <UguiSprite>("shadow", 0);
                    {
                        shadow.Anchor     = AnchorType.Fill;
                        shadow.Offset     = new Offset(-7f);
                        shadow.SpriteName = "glow-circle-16";
                        shadow.ImageType  = Image.Type.Sliced;
                        shadow.Color      = Color.black;
                    }
                    listContainer = aniHolder.CreateChild <UguiListView>("list", 1);
                    {
                        listContainer.Anchor = AnchorType.Fill;
                        listContainer.Offset = Offset.Zero;
                        listContainer.Background.SpriteName = "circle-16";
                        listContainer.Background.ImageType  = Image.Type.Sliced;
                        listContainer.Background.Color      = new Color(0f, 0f, 0f, 0.75f);

                        listContainer.Initialize(OnCreateMenuItem, OnUpdateMenuItem);
                        listContainer.CellSize = ItemSize;
                        listContainer.Corner   = GridLayoutGroup.Corner.UpperLeft;
                        listContainer.Axis     = GridLayoutGroup.Axis.Vertical;
                    }
                }
            }

            showAni = new Anime();
            showAni.AddEvent(0f, () => Active           = true);
            showAni.AnimateFloat(a => canvasGroup.alpha = a)
            .AddTime(0f, () => canvasGroup.alpha)
            .AddTime(0.25f, 1f)
            .Build();
            showAni.AnimateFloat(y => aniHolder.Y = y)
            .AddTime(0f, MoveAniAmount, EaseType.QuadEaseOut)
            .AddTime(0.25f, 0f)
            .Build();

            hideAni = new Anime();
            hideAni.AnimateFloat(a => canvasGroup.alpha = a)
            .AddTime(0f, () => canvasGroup.alpha)
            .AddTime(0.25f, 0f)
            .Build();
            hideAni.AnimateFloat(y => aniHolder.Y = y)
            .AddTime(0f, 0f, EaseType.QuadEaseOut)
            .AddTime(0.25f, MoveAniAmount)
            .Build();
            hideAni.AddEvent(hideAni.Duration, () =>
            {
                OnHidden?.Invoke(this);
                Active = false;
            });
        }