using System.Collections.Generic; using System.Linq; using TMPro; using UnityEngine; using UnityEngine.SceneManagement; using UnityEngine.UI; public class KleinerSternMenu : MonoBehaviour { public string nameOfThisScene; public GameObject buttonPrefab; private class SceneWithMeta { public string displayName; public string internalName; public SceneWithMeta(string internalName, string displayName){ this.displayName = displayName; this.internalName = internalName; } } private readonly List sceneList = new List { new("kleiner_Stern_1", "Szene 1: Sternenhimmel"), new("kleiner_Stern_2", "Szene 2: Wald"), new("kleiner_Stern_3", "Szene 3: Freies Feld"), new("kleiner_Stern_4", "Szene 4: Herberge"), new("kleiner_Stern_5", "Szene 5: Stall"), new("kleiner_Stern_6", "Szene 6: Stall") }; private bool visible; private List buttons; // Start is called once before the first execution of Update after the MonoBehaviour is created void Start() { visible = false; sceneList.Add(new("Hauptmenu", "Zum Hauptmenü")); buttons = new(); float y = 20; sceneList.Reverse(); foreach (SceneWithMeta s in sceneList) { GameObject b = Instantiate(buttonPrefab, transform, false); RectTransform tr = b.GetComponent(); tr.anchorMin = Vector2.zero; tr.anchorMax = Vector2.zero; tr.anchoredPosition = new(20, y); tr.pivot = Vector2.zero; y += 50; b.GetComponentInChildren().text = s.displayName; b.GetComponent