using UniFramework.Pooling; using UnityEngine; using YooAsset; namespace GFGGame { public class AssetReleaser : MonoBehaviour { private string resPath; public string ResPath { get { return resPath; } } private AssetOperationHandle assetOperationHandle; private SpawnHandle spawnHandle; public bool IsSpawn { get { return spawnHandle != null; } } public void SetRes(string resPath, AssetOperationHandle handle) { Dispose(); this.resPath = resPath; this.assetOperationHandle = handle; } public void SetSpawn(string resPath, SpawnHandle handle) { this.resPath = resPath; this.spawnHandle = handle; } private void OnDestroy() { //if (!string.IsNullOrEmpty(resPath)) //{ // GFGAsset.Release(resPath); //} // resPath = string.Empty; Dispose(); } private void Dispose() { this.assetOperationHandle?.Release(); this.assetOperationHandle = null; this.spawnHandle = null; this.resPath = null; } public void Restore() { this.spawnHandle?.Restore(); this.spawnHandle = null; } } }