Beispiel #1
0
        private void Awake()
        {
            backToGameButton.onClick.AddListener(ui.ShowGameUi);

            foreach (PlanetSettings planetSettings in mainSettings.PlanetsSettings)
            {
                Button newPlanetButton = InitNewPlanetButton(planetSettings);
                newPlanetButton.onClick.AddListener(delegate(){ OnPlanetSelected?.Invoke(planetSettings.PlanetName); });
                planetsButtons.Add(newPlanetButton);
            }
        }
        private void CreatePlanetButtons()
        {
            foreach (var settings in PlanetSettingsList)
            {
                var buttonObject  = Instantiate(_buttonPrefab, _buttonsHolder);
                var buttonElement = buttonObject.GetComponent <PlanetButtonElement>();

                if (buttonElement == null)
                {
                    throw new System.ArgumentException($"Prefab must contain {nameof(PlanetButtonElement)}.");
                }

                buttonElement.Fill(settings, () => OnPlanetSelected?.Invoke(settings));
            }
        }