public void AddSection(
            SettingsButtonEntry newMenuButton,
            ISettingsSectionView newSection,
            ISettingsSectionController newSectionController,
            SettingsSectionModel sectionConfig)
        {
            newMenuButton?.Initialize(sectionConfig.icon, sectionConfig.text);

            newSection.Initialize(newSectionController, sectionConfig.widgets.ToList());
            newSection.SetActive(false);
            sections.Add(newSection);

            newMenuButton?.ConfigureAction(() =>
            {
                foreach (var button in menuButtons)
                {
                    button.MarkAsSelected(false);
                }
                newMenuButton.MarkAsSelected(true);

                OpenSection(newSection);
            });

            menuButtons.Add(newMenuButton);
        }
示例#2
0
        public IEnumerator GenerateSectionsIntoThePanelViewCorrectly()
        {
            // Arrange
            SettingsSectionView sectionViewPrefab = ((GameObject)Resources.Load(SECTION_VIEW_PREFAB_PATH)).GetComponent <SettingsSectionView>();
            SettingsButtonEntry menuButtonPrefab  = ((GameObject)Resources.Load(MENU_BUTTON_PREFAB_PATH)).GetComponent <SettingsButtonEntry>();

            SettingsSectionModel newSectionConfig = ScriptableObject.CreateInstance <SettingsSectionModel>();

            newSectionConfig.icon              = Sprite.Create(new Texture2D(10, 10), new Rect(), new Vector2());
            newSectionConfig.text              = "TestSection";
            newSectionConfig.menuButtonPrefab  = menuButtonPrefab;
            newSectionConfig.sectionPrefab     = sectionViewPrefab;
            newSectionConfig.sectionController = ScriptableObject.CreateInstance <SettingsSectionController>();
            newSectionConfig.widgets           = new SettingsWidgetList();

            sectionsToCreate.Add(newSectionConfig);

            // Act
            panelView.Initialize(hudController, panelController, sectionsToCreate);
            yield return(null);

            // Assert
            panelController.Received(1)
            .AddSection(
                Arg.Any <SettingsButtonEntry>(),
                Arg.Any <ISettingsSectionView>(),
                Arg.Any <ISettingsSectionController>(),
                Arg.Any <SettingsSectionModel>());

            panelController.Received(1).OpenSection(0);
            panelController.Received(1).MarkMenuButtonAsSelected(0);
        }