ofb/Assets/Prefabs/DEBUG/DEBUG_persistent_data.cs
Sam 16a190949d created victory object and level progression
also tried to create a way to launch the game from any scene, but it doesn't really work. don't use anything in the folder called "DEBUG"
2023-04-30 13:34:02 -07:00

35 lines
1.1 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class DEBUG_persistent_data : MonoBehaviour
{
[Header("PERSISTENT DATA OBJECTS")]
[SerializeField] GameObject stateControllerPrefab;
[SerializeField] GameObject sceneManagerPrefab;
[SerializeField] GameObject debugCanvasPrefab;
void Start() {
// check to see if a DEBUG already exists
if (GameObject.FindGameObjectWithTag("DEBUG") != null) {
Destroy(this.gameObject);
} else { // if it doesn't, then this is the only one
this.gameObject.tag = "DEBUG";
}
// create persistent data, state controller, scene manager if they don't exist
if (GameObject.FindGameObjectWithTag("StateController") == null) {
Instantiate(stateControllerPrefab);
}
if (GameObject.FindGameObjectWithTag("SceneManager") == null) {
Instantiate(sceneManagerPrefab);
}
if (GameObject.FindGameObjectWithTag("DebugCanvas") == null) {
Instantiate(debugCanvasPrefab);
}
}
}