Advertisement
eastbayeff

Untitled

Jun 3rd, 2022
1,202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.15 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEditor;
  4. using UnityEngine;
  5.  
  6.  
  7. public class LevelButtonGenerator : MonoBehaviour {
  8.     public LevelSelectDude buttonPrefab;
  9.     public Transform buttonPanelContainer;
  10.     private List<string> scenes;
  11.     private List<GameObject> buttons;
  12.     public PlayerData playerData;
  13.  
  14.    
  15.     void Start () {
  16.         scenes = new List<string>();
  17.         buttons = new List<GameObject>();
  18.         foreach (var scene in EditorBuildSettings.scenes)
  19.         {
  20.             if (scene.enabled)
  21.             {
  22.                 scenes.Add(scene.path);
  23.                 var button = Instantiate(buttonPrefab, buttonPanelContainer);
  24.                 button.SetBuildTarget(scene.path);
  25.                 buttons.Add(button.gameObject);
  26.                
  27.             }
  28.         }
  29.  
  30.         //remove home screen and you win screen
  31.         buttons[45].SetActive(false);
  32.         buttons[0].SetActive(false);
  33.         for (int i=0; i < buttons.Count; i++)
  34.         {
  35.             if (i > playerData.highestBuildIndexCompleted)
  36.             {
  37.                 buttons[i].SetActive(false);
  38.             }
  39.         }
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement