Files
Darklings-FightingGame/Assets/_Project/Scripts/HelperScripts/DontDestroyOnLoad.cs
2023-08-28 02:38:39 +03:00

23 lines
530 B
C#

using UnityEngine;
namespace Demonics.Utility
{
public class DontDestroyOnLoad : MonoBehaviour
{
private static DontDestroyOnLoad instance;
void Awake()
{
if (instance != null && instance != this)
{
Destroy(this.gameObject);
return;
}
else
{
this.transform.SetParent(null);
instance = this;
}
DontDestroyOnLoad(this.gameObject);
}
}
}