You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
392 B
24 lines
392 B
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);
|
|
}
|
|
}
|
|
} |