24 lines
392 B
C#
Raw Permalink Normal View History

2021-03-22 19:20:51 +08:00
namespace Mapbox.Unity.Utilities
{
using UnityEngine;
public class DontDestroyOnLoad : MonoBehaviour
{
static DontDestroyOnLoad _instance;
[SerializeField]
bool _useSingleInstance;
protected virtual void Awake()
{
if (_instance != null && _useSingleInstance)
{
Destroy(gameObject);
return;
}
_instance = this;
DontDestroyOnLoad(gameObject);
}
}
}