Hallo,
ich bin im Moment dabei, mir selbst Unity bei zu bringen. Wie man sieht habe ich aber Probleme.
Was ich machen möchte ist eigentlich recht simple - Ich möchte eine Intro-Sequenz am Anfang des Spiels haben, die 3 Texte nacheinander Visible macht und dann am Ende kann man dann drücken um das Spiel zu starten, sprich den Intro Frame unsichtbar zu machen. Ich habe aber nur Probleme mit dem "wait" Befehl, da dieser hier komischerweise sehr unnötog kompliziert gemacht wurde. Anstatt eines einfachen "wait()-Befehls" oder so muss man ja irgendwas mit diesen "IEnumeratorn" machen. Ich habe mir auch schon Tutorials angeschaut, komme hier aber nicht zu irgendeinem guten Ergebnis, sobald ich die wait Funktion nutze.
Kennt sich hier vielleicht irgendjemand aus? Wäre sehr cool wenn ihr mir helft.
Nur zu Info: Ich bin kein Profi, also bitte hatet mich nicht wenn es sehr offensichtlich ist oder so.
Hier mein Script:
using System.Collections;
using System.Collections.Generic;
using Unity.VisualScripting;
using UnityEngine;
using UnityEngine.UI;
public class Script1 : MonoBehaviour
{
public GameObject Intro;
public GameObject StartText;
public GameObject Text1;
public GameObject Text2;
public GameObject Text3;
public bool IsEnabled = false;
// Start is called before the first frame update
void Start()
{
Text1.SetActive(false);
Text2.SetActive(false);
Text3.SetActive(false);
StartText.SetActive(false);
Initialise();
}
IEnumerator Initialise()
{
Text1.SetActive(true);
yield return new WaitForSeconds(2f);
Text2.SetActive(true);
yield return new WaitForSeconds(2f);
Text3.SetActive(true);
yield return new WaitForSeconds(2f);
StartText.SetActive(true);
IsEnabled = true;
}
// Update is called once per frame
void Update()
{
if (IsEnabled == true)
{
if (Input.GetKeyDown(KeyCode.Mouse0))
{
Intro.SetActive(false);
IsEnabled = false;
}
}
}
}
Hier nochmal als Bild aus Visual Studio falls es jemand braucht: