Tanoda
TutorialInjector.cs
Go to the documentation of this file.
1using System.Collections;
2using System.Collections.Generic;
3using UnityEngine;
4using UnityEngine.SceneManagement;
5
6public class TutorialInjector : MonoBehaviour
7{
8 public AudioClip ac;
9
10 internal int menuscene = 0;
11 internal int loadScene = 1;
12
13 // Start is called before the first frame update
14 IEnumerator Start()
15 {
16 while (SceneManager.GetActiveScene().buildIndex != menuscene)
17 {
18 yield return null;
19 }
20
21 SceneManager.LoadSceneAsync(loadScene);
22
23 while (SceneManager.GetActiveScene().buildIndex != loadScene)
24 {
25 yield return null;
26 }
27
28 yield return new WaitForSeconds(0.5f);
29
30 while (LoadingManager.instance.isLoading)
31 {
32 yield return new WaitForEndOfFrame();
33 }
34
35 yield return new WaitForSeconds(5.5f);
36
37 if (loadScene == 1)
38 {
39 var aus = gameObject.AddComponent<AudioSource>();
40 aus.clip = ac;
41 aus.Play();
42 MiscLogicManager.instance.OnEnded?.AddListener(FindObjectOfType<GazeRestarter>().OnLevelEnded);
43 while (aus.isPlaying)
44 {
45 yield return new WaitForEndOfFrame();
46 }
47 }
48
49 Destroy(gameObject);
50 }
51
52}