WXMC/proj/unity/Assets/Scripts/SingletonGO.cs
2024-12-04 16:18:46 +08:00

28 lines
521 B
C#

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