28 lines
521 B
C#
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);
|
|
}
|
|
}
|
|
}
|