Files
5.24BuYu/Assets/MyGame/Framework/Scenes/DontDestroyMgr.cs
T
2026-10-14 19:39:24 +08:00

26 lines
566 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class DontDestroyMgr : Singleton<DontDestroyMgr>
{
List<GameObject> dontDesObj = new List<GameObject>();
public void DontDesOnLoad(GameObject obj)
{
if(!dontDesObj.Contains(obj))
{
Object.DontDestroyOnLoad(obj);
dontDesObj.Add(obj);
}
}
public void Clear()
{
foreach(GameObject obj in dontDesObj)
{
Object.DestroyImmediate(obj);
}
dontDesObj.Clear();
}
}