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.
mapbox-sdk/Unity/Utilities/DontDestroyOnLoad.cs

24 lines
392 B

6 months ago
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);
}
}
}