示例#1
0
        private void Init()
        {
            container = CreateChild <UguiObject>("container", 0);
            {
                container.Anchor = AnchorType.TopStretch;
                container.Pivot  = PivotType.Top;
                container.Y      = 0f;
                container.SetOffsetHorizontal(0f);
                container.Height = FoldedHeight;

                providerContainer = container.CreateChild <ProviderContainer>("provider", 1);
                {
                    providerContainer.Anchor = AnchorType.TopStretch;
                    providerContainer.Pivot  = PivotType.Top;
                    providerContainer.SetOffsetHorizontal(0f);
                    providerContainer.Y      = 0f;
                    providerContainer.Height = ProviderControllerHeight;
                }
                bannerContainer = container.CreateChild <BannerContainer>("banner", 0);
                {
                    bannerContainer.Anchor         = AnchorType.Fill;
                    bannerContainer.Offset         = new Offset(0f, 54f, 0f, 96f);
                    bannerContainer.IsInteractible = false;
                }
                searchBarContainer = container.CreateChild <SearchBarContainer>("search-bar", 2);
                {
                    searchBarContainer.Anchor = AnchorType.BottomStretch;
                    searchBarContainer.Pivot  = PivotType.Bottom;
                    searchBarContainer.SetOffsetHorizontal(0f);
                    searchBarContainer.Y      = 0f;
                    searchBarContainer.Height = SearchBarHeight;

                    searchBarContainer.AdvancedButton.OnTriggered += OnAdvancedButton;
                }
            }
            shadowButton = CreateChild <ShadowButton>("shadow", 1);
            {
                shadowButton.Anchor = AnchorType.Fill;
                shadowButton.Offset = new Offset(0f, FoldedHeight, 0f, 0f);
                shadowButton.Active = false;
                shadowButton.Alpha  = 0f;

                shadowButton.OnTriggered += OnShadowButton;
            }
            scrollTopButton = CreateChild <ScrollTopButton>("scroll-button", 2);
            {
                scrollTopButton.Anchor = AnchorType.Bottom;
                scrollTopButton.Y      = -28f;
                scrollTopButton.Size   = new Vector2(120f, 24f);
                scrollTopButton.Active = false;

                scrollTopButton.OnTriggered += OnScrollTopButton;
            }

            foldAni = new Anime();
            foldAni.AddEvent(0f, () => bannerContainer.IsInteractible = false);
            foldAni.AnimateFloat(h =>
            {
                container.Height = h;
                shadowButton.SetOffsetTop(h);
                bannerContainer.AdjustBannerTexture();
            })
            .AddTime(0f, () => container.Height)
            .AddTime(0.25f, FoldedHeight)
            .Build();
            foldAni.AnimateFloat(a => shadowButton.Alpha = a)
            .AddTime(0f, () => shadowButton.Alpha)
            .AddTime(0.25f, 0f)
            .Build();
            foldAni.AddEvent(0f, () => shadowButton.Active = false);

            unfoldAni = new Anime();
            unfoldAni.AddEvent(0f, () => shadowButton.Active = true);
            unfoldAni.AnimateFloat(h =>
            {
                container.Height = h;
                shadowButton.SetOffsetTop(h);
                bannerContainer.AdjustBannerTexture();
            })
            .AddTime(0f, () => container.Height)
            .AddTime(0.25f, UnfoldedHeight)
            .Build();
            unfoldAni.AnimateFloat(a => shadowButton.Alpha = a)
            .AddTime(0f, () => shadowButton.Alpha)
            .AddTime(0.25f, 0.5f)
            .Build();
            unfoldAni.AddEvent(unfoldAni.Duration, () => bannerContainer.IsInteractible = true);

            scrollButtonShowAni = new Anime();
            scrollButtonShowAni.AddEvent(0f, () => scrollTopButton.Active = true);
            scrollButtonShowAni.AnimateFloat((i) =>
            {
                scrollTopButton.Alpha = Easing.Linear(i, 0f, 1f, 0f);
                scrollTopButton.Y     = Easing.Linear(i, 0f, 28f, 0f);
            }).AddTime(0f, 0f, EaseType.BackEaseOut)
            .AddTime(0.25f, 1f)
            .Build();

            scrollButtonHideAni = new Anime();
            scrollButtonHideAni.AnimateFloat((i) =>
            {
                scrollTopButton.Alpha = Easing.Linear(i, 1f, -1f, 0f);
                scrollTopButton.Y     = Easing.Linear(i, 28f, -28f, 0f);
            }).AddTime(0f, 0f, EaseType.SineEaseOut)
            .AddTime(0.25f, 1f)
            .Build();
            scrollButtonHideAni.AddEvent(scrollButtonHideAni.Duration, () => scrollTopButton.Active = false);

            OnEnableInited();
        }
示例#2
0
        private void Init()
        {
            container = CreateChild <UguiObject>("container");
            {
                container.Anchor = AnchorType.TopStretch;
                container.Pivot  = PivotType.Top;
                container.SetOffsetHorizontal(0f);
                container.Height = ContainerHeight;
                container.Y      = 0f;

                backgroundSprite = container.CreateChild <BackgroundSprite>("background");
                {
                    backgroundSprite.Anchor  = AnchorType.Fill;
                    backgroundSprite.RawSize = Vector2.zero;
                    backgroundSprite.SetOffsetVertical(0f);
                }

                comboMenuButton = container.CreateChild <ComboMenuButton>("combo-menu");
                {
                    comboMenuButton.Anchor = AnchorType.LeftStretch;
                    comboMenuButton.Pivot  = PivotType.Left;
                    comboMenuButton.SetOffsetVertical(0f);
                    comboMenuButton.X     = 0f;
                    comboMenuButton.Width = 80f;
                }
                profileButton = container.CreateChild <ProfileMenuButton>("profile-menu");
                {
                    profileButton.Anchor = AnchorType.LeftStretch;
                    profileButton.Pivot  = PivotType.Left;
                    profileButton.SetOffsetVertical(0f);
                    profileButton.X     = comboMenuButton.Width;
                    profileButton.Width = 220f;
                }
                modeButton = container.CreateChild <ModeMenuButton>("mode-menu");
                {
                    modeButton.Anchor = AnchorType.LeftStretch;
                    modeButton.Pivot  = PivotType.Left;
                    modeButton.SetOffsetVertical(0f);
                    modeButton.X     = profileButton.X + profileButton.Width;
                    modeButton.Width = 80f;
                }

                notificationMenuButton = container.CreateChild <NotificationMenuButton>("notification-menu");
                {
                    notificationMenuButton.Anchor = AnchorType.RightStretch;
                    notificationMenuButton.Pivot  = PivotType.Right;
                    notificationMenuButton.SetOffsetVertical(0f);
                    notificationMenuButton.X     = 0f;
                    notificationMenuButton.Width = 80f;
                }
                settingsMenuButton = container.CreateChild <SettingsMenuButton>("settings-menu");
                {
                    settingsMenuButton.Anchor = AnchorType.RightStretch;
                    settingsMenuButton.Pivot  = PivotType.Right;
                    settingsMenuButton.SetOffsetVertical(0f);
                    settingsMenuButton.X     = -notificationMenuButton.Width;
                    settingsMenuButton.Width = 80f;
                }
                musicButton = container.CreateChild <MusicButton>("music-menu");
                {
                    musicButton.Anchor = AnchorType.RightStretch;
                    musicButton.Pivot  = PivotType.Right;
                    musicButton.SetOffsetVertical(0f);
                    musicButton.X     = settingsMenuButton.X - settingsMenuButton.Width;
                    musicButton.Width = 80f;
                }
            }

            menuButtons = GetComponentsInChildren <BaseMenuButton>(true);

            OnEnableInited();
        }