AssetReleaser.cs 940 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. using System.Collections;
  2. using UnityEngine;
  3. using YooAsset;
  4. namespace GFGGame
  5. {
  6. public class AssetReleaser : MonoBehaviour
  7. {
  8. private string _resPath;
  9. public string resPath
  10. {
  11. get
  12. {
  13. return _resPath;
  14. }
  15. }
  16. private AssetOperationHandle _handle;
  17. public void SetRes(string resPath, AssetOperationHandle handle)
  18. {
  19. Dispose();
  20. this._resPath = resPath;
  21. this._handle = handle;
  22. }
  23. private void OnDestroy()
  24. {
  25. //if (!string.IsNullOrEmpty(resPath))
  26. //{
  27. // GFGAsset.Release(resPath);
  28. //}
  29. // resPath = string.Empty;
  30. Dispose();
  31. }
  32. private void Dispose()
  33. {
  34. this._handle?.Release();
  35. this._handle = null;
  36. this._resPath = null;
  37. }
  38. }
  39. }