HeavenStudioPlus/Assets/Scripts/Initializer.cs

59 lines
2.1 KiB
C#
Raw Normal View History

2022-01-03 22:42:43 +00:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace RhythmHeavenMania
{
public class Initializer : MonoBehaviour
{
public TextAsset level;
public AudioClip music;
2022-01-06 00:11:33 +00:00
public bool debugUI;
public bool playOnStart = false;
public bool editor = false;
2022-01-03 22:42:43 +00:00
private void Start()
{
GameObject Cameras = Instantiate(Resources.Load<GameObject>("Prefabs/Cameras")); Cameras.name = "Cameras";
GameObject MainCamera = Cameras.transform.GetChild(0).gameObject;
GameObject CursorCamera = Cameras.transform.GetChild(1).gameObject;
GameObject Cursor = Instantiate(Resources.Load<GameObject>("Prefabs/Cursor"));
Cursor.name = "Cursor";
GameObject Games = new GameObject();
Games.name = "Games";
GameObject GameManager = new GameObject();
GameManager.name = "GameManager";
GameManager gameManager = GameManager.AddComponent<GameManager>();
2022-01-06 00:11:33 +00:00
if (playOnStart) gameManager.playOnStart = true;
2022-01-03 22:42:43 +00:00
gameManager.txt = level;
gameManager.GamesHolder = Games;
gameManager.CircleCursor = Cursor.transform.GetChild(0).GetComponent<CircleCursor>();
gameManager.GameCamera = MainCamera.GetComponent<Camera>();
gameManager.CursorCam = CursorCamera.GetComponent<Camera>();
GameObject Profiler = Instantiate(Resources.Load<GameObject>("Prefabs/GameProfiler"));
Profiler.name = "GameProfiler";
2022-01-06 00:11:33 +00:00
if (!debugUI)
{
Profiler.GetComponent<DebugUI>().enabled = false;
Profiler.transform.GetChild(0).gameObject.SetActive(false);
}
2022-01-03 22:42:43 +00:00
GameObject Conductor = new GameObject();
Conductor.name = "Conductor";
Conductor.AddComponent<AudioSource>().clip = music;
Conductor.AddComponent<Conductor>();
Conductor.AddComponent<AudioDspTimeKeeper>();
2022-01-06 00:11:33 +00:00
if (editor)
{
this.GetComponent<RhythmHeavenMania.Editor.Editor>().Init();
}
2022-01-03 22:42:43 +00:00
}
}
}