Advertisement
Denisimus

GenerateLevelesBatons

Jan 31st, 2023
724
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.13 KB | None | 0 0
  1. namespace Levels.UI
  2. {
  3.     public class GenerateLevelesBatons : MonoBehaviour
  4.     {
  5.         [SerializeField] private GameObject[] buttons;
  6.         [SerializeField] private GameObject menu;
  7.         [SerializeField] private GameObject leveles;
  8.  
  9.  
  10.         [SerializeField] private int quantityLevels;
  11.         private GameObject _buttonNewGamePerfab;
  12.         private GameObject _buttonLevelPrefab;
  13.         private GameObject _buttonXitPrefab;
  14.         private int levelNamber;
  15.  
  16.  
  17.         // Start is called before the first frame update
  18.         void Start()
  19.         {
  20.             levelNamber = 1;
  21.             // Instantiate(buttonLevelPrefab, new Vector3(0, 0, 0), Quaternion.identity);
  22.             _buttonNewGamePerfab = buttons[0];
  23.             _buttonLevelPrefab = buttons[1];
  24.             _buttonXitPrefab = buttons[2];
  25.  
  26.             StartCoroutine(GenerateLevelesList());
  27.        
  28.         }
  29.  
  30.         IEnumerator GenerateLevelesList()
  31.         {
  32.             // Instantiate(_buttonNewGamePerfab, menu.transform);
  33.  
  34.             while (quantityLevels != levelNamber)
  35.             {
  36.                 // Instantiate(buttonLevelPrefab, new Vector3(0, 0, 0), Quaternion.identity);
  37.                 // create a new Goal Panelat the goalIntroParent Position
  38.                 var buttonLevelPrefab = SetNumberOfLevel();
  39.                 Instantiate(buttonLevelPrefab, leveles.transform);
  40.            
  41.                 quantityLevels--;
  42.                 levelNamber++;
  43.             }
  44.        
  45.             // Instantiate(_buttonXitPrefab, menu.transform);
  46.  
  47.  
  48.             return null;
  49.         }
  50.  
  51.         private GameObject SetNumberOfLevel()
  52.         {
  53.             GameObject buttonLevelPrefab = _buttonLevelPrefab;
  54.  
  55.             var child = buttonLevelPrefab.transform.GetChild(0);
  56.             var text = child.GetComponent<TextMeshProUGUI>().text;
  57.             child.GetComponent<TextMeshProUGUI>().text = text + levelNamber;
  58.  
  59.  
  60.             buttonLevelPrefab.name = "buttonLevel" + levelNamber;
  61.             return buttonLevelPrefab;
  62.         }
  63.  
  64.  
  65.         // Update is called once per frame
  66.  
  67. //TODO sow opens leveles
  68. //TODO OpenlevelByclic  
  69.     }
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement