ofb/Assets/Prefabs/DEBUG/DEBUG_persistent_data.cs

35 lines
1.1 KiB
C#
Raw Permalink Normal View History

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);
}
}
}