/// <summary> /// Create and instantiate a level select button base on item /// </summary> /// <param name="item">The level data</param> /// <returns>The created button</returns> protected LevelSelectButton CreateButton(LevelItem item) { LevelSelectButton button = Instantiate(SelectionPrefab); button.Initialize(item); return(button); }
void Start() { for (int i = 0; i <= PlaySessionManager.ins.FurthestLevel; i++) { LevelSelectButton newButton = Instantiate(buttonPrefab, buttonContainer); newButton.Initialize(this, i); } }
private void InitializeLevelsList() { for (int i = 0; i < levels.levels.Length; i++) { level l = levels.levels[i]; GameObject levelObject = Instantiate(levelPrefab, levelContentGroup.transform); LevelSelectButton levelSelectButton = levelObject.GetComponent <LevelSelectButton>(); levelSelectButton.level = l; levelSelectButton.Initialize(); } }
private void InitLevelSelectButtons() { LevelSelectButton[] existingButtons = GetComponentsInChildren <LevelSelectButton>(); foreach (LevelSelectButton button in existingButtons) { Destroy(button.gameObject); } for (int i = 0; i < levelsCount; i++) { LevelSelectButton levelSelectButton = Instantiate(levelSelectButtonPrefab, transform); levelSelectButton.Initialize(this, i, unlockedLevels.Contains(i)); } }