using System.Collections.Generic; using UnityEngine; using System.Collections; using ICTS.Localization; using TMPro; using UnityEngine.UI; public class LevelSelector : MonoBehaviour { public GameObject levelButtonPrefab; public GameObject parent; public List ButtonLevelSelectors = new List(); const int OFFSET = 140; const int BUTTON_SPACING = 120; void Start() { //PlayerPrefs.SetInt("Level", 5); int numOfLevels = LevelsManager.Instance.levels.Length; int posY = OFFSET; for (int i = 0; i < numOfLevels; i++) { var go = (GameObject)Instantiate(levelButtonPrefab); go.transform.SetParent(parent.transform); Transform button = go.transform; //Vector3 pos = new Vector3(0, posY, 0); button.localPosition = Vector3.zero; button.localScale = Vector3.one; // -= BUTTON_SPACING; var label = button.GetComponentInChildren(); label.text = string.Format(Localization.instance.Get("levelButton.text"), i+1); //+1 since players prefer 1-based ButtonLevelSelector buttonLevelSelector = button.GetComponent(); buttonLevelSelector.levelIndex = i; ButtonLevelSelectors.Add(buttonLevelSelector); } ActivateCountButtonLevel(); } void ActivateCountButtonLevel() { int playerLevelDone = PlayerPrefs.GetInt("LevelDone"); if(playerLevelDone==0) { PlayerPrefs.SetInt("LevelDone", 1); } //Debug.Log(playerLevel); for (int i = 0; i < ButtonLevelSelectors.Count; i++) { if(i>playerLevelDone-1) { ButtonLevelSelectors[i].GetComponent