public override void Awake() { #if UNITY_EDITOR if (!Application.isPlaying) { return; } #endif base.Awake(); firstLevelBuildIndex = _firstLevelBuildIndex; parTimes = _parTimes; scoresToUnlock = _scoresToUnlock; scoreText.text = "Score: " + GameManager.Score; survivalButton.interactable = Survival.Unlocked; LevelMap.previousLevelName = ""; levelButtons = GetComponentsInChildren <LevelButton>(); foreach (LevelButton levelButton in levelButtons) { levelButton.level = new Level(); levelButton.level.name = levelButton.nameText.text; levelButton.Start(); } LevelButton previousLevelButton = levelButtons[PreviousLevelIndex]; previousLevelButton.Start(); previousLevelButton.SetLevel(); UIControlManager.Instance.ChangeSelected(previousLevelButton); startButton.onClick.AddListener(StartSelectedLevel); }
public virtual void Update() { if (addNewButton) { addNewButton = false; LevelButton button = Instantiate(levelButtonPrefab); button.trs.SetParent(trs); button.trs.localScale = Vector3.one; EditorBuildSettingsScene scene = EditorBuildSettings.scenes[_firstLevelBuildIndex + button.trs.GetSiblingIndex()]; string sceneName = scene.path.Substring(scene.path.LastIndexOf("/") + 1).Replace(".unity", ""); button.name = sceneName + " [" + button.trs.GetSiblingIndex() + "]"; button.levelName = sceneName; button.nameText.text = sceneName; } foreach (LevelButton levelButton in levelButtons) { levelButton.level.extraScenes = levelButton.extraScenes; levelButton.level.name = levelButton.levelName; } }