Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace Levels.UI
- {
- public class GenerateLevelesBatons : MonoBehaviour
- {
- [SerializeField] private GameObject[] buttons;
- [SerializeField] private GameObject menu;
- [SerializeField] private GameObject leveles;
- [SerializeField] private int quantityLevels;
- private GameObject _buttonNewGamePerfab;
- private GameObject _buttonLevelPrefab;
- private GameObject _buttonXitPrefab;
- private int levelNamber;
- // Start is called before the first frame update
- void Start()
- {
- levelNamber = 1;
- // Instantiate(buttonLevelPrefab, new Vector3(0, 0, 0), Quaternion.identity);
- _buttonNewGamePerfab = buttons[0];
- _buttonLevelPrefab = buttons[1];
- _buttonXitPrefab = buttons[2];
- StartCoroutine(GenerateLevelesList());
- }
- IEnumerator GenerateLevelesList()
- {
- // Instantiate(_buttonNewGamePerfab, menu.transform);
- while (quantityLevels != levelNamber)
- {
- // Instantiate(buttonLevelPrefab, new Vector3(0, 0, 0), Quaternion.identity);
- // create a new Goal Panelat the goalIntroParent Position
- var buttonLevelPrefab = SetNumberOfLevel();
- Instantiate(buttonLevelPrefab, leveles.transform);
- quantityLevels--;
- levelNamber++;
- }
- // Instantiate(_buttonXitPrefab, menu.transform);
- return null;
- }
- private GameObject SetNumberOfLevel()
- {
- GameObject buttonLevelPrefab = _buttonLevelPrefab;
- var child = buttonLevelPrefab.transform.GetChild(0);
- var text = child.GetComponent<TextMeshProUGUI>().text;
- child.GetComponent<TextMeshProUGUI>().text = text + levelNamber;
- buttonLevelPrefab.name = "buttonLevel" + levelNamber;
- return buttonLevelPrefab;
- }
- // Update is called once per frame
- //TODO sow opens leveles
- //TODO OpenlevelByclic
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement