using UnityEngine;
namespace Ashwild.Core
{
///
/// Helper for managers that must outlive scene loads. It detaches the object to the scene root
/// (DontDestroyOnLoad only works on root objects) and marks it persistent — call it from Awake.
///
/// This is what lets a persistent manager sit under a tidy "Managers" parent in the editor next
/// to NON-persistent ones: only the objects that call Persist leave the parent and survive across
/// scenes; the rest stay children of the parent and are destroyed with the scene as usual.
///
public static class Persistence
{
///
/// Moves the GameObject to the scene root and keeps it alive across scene loads.
///
public static void Persist(GameObject go)
{
if (go == null) return;
go.transform.SetParent(null);
Object.DontDestroyOnLoad(go);
}
}
}