using System.Collections; using System.Collections.Generic; using UnityEngine; public class SingletonGO : MonoBehaviour { public static SingletonGO main; public List CreatePrefabs; private void Awake() { if (main != null) { Destroy(gameObject); return; } DontDestroyOnLoad(gameObject); main = this; foreach (GameObject prefab in CreatePrefabs) { Instantiate(prefab, transform); } } }