diff --git a/Assets/HauptmenuSteuerung.cs b/Assets/HauptmenuSteuerung.cs new file mode 100644 index 0000000..8578557 --- /dev/null +++ b/Assets/HauptmenuSteuerung.cs @@ -0,0 +1,26 @@ +using UnityEngine; +using UnityEngine.SceneManagement; + +public class HauptmenuSteuerung : MonoBehaviour +{ + // Start is called once before the first execution of Update after the MonoBehaviour is created + void Start() + { + + } + + // Update is called once per frame + void Update() + { + + } + + public void StarteKrippenspiel(string titel){ + string name = titel + "_1"; + SceneManager.LoadScene(name); + } + + public void Ende(){ + Application.Quit(); + } +} diff --git a/Assets/HauptmenuSteuerung.cs.meta b/Assets/HauptmenuSteuerung.cs.meta new file mode 100644 index 0000000..34994fd --- /dev/null +++ b/Assets/HauptmenuSteuerung.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: e212734e919ce1c9fa41a816c0d99cfa \ No newline at end of file diff --git a/Assets/KleinerSternMenu.cs b/Assets/KleinerSternMenu.cs new file mode 100644 index 0000000..ac2d88d --- /dev/null +++ b/Assets/KleinerSternMenu.cs @@ -0,0 +1,68 @@ +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