1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- 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;
- }
- }
- }
|