12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- using UnityEngine;
- using System.Collections;
- using System.Collections.Generic;
- namespace Engine.CLoader
- {
- /// <summary>内存中的资源对象</summary>
- internal class CAssetsInfo
- {
- /// <summary>资源的AssetBundle 对象</summary>
- public AssetBundle assetsBundle;
- /// <summary>资源包名称</summary>
- public string assetsName;
- /// <summary>资源依赖的资源包</summary>
- public List<CAssetsInfo> depAssetsList = new List<CAssetsInfo>();
- /// <summary>是否为空资源</summary>
- public bool isEmpty = true;
- /// <summary>资源使用计算</summary>
- private int useCount = 0;
- /// <summary>减少使用计数</summary>
- public void DelUseCount()
- {
- useCount--;
- //特出处理
- useCount = (useCount < 0) ? 0 : useCount;
- if(useCount==0)
- {
- this.Dispose();
- }
- }
- /// <summary>增加使用基数</summary>
- public void AddUseCount()
- {
- useCount++;
- }
- /// <summary>释放函数</summary>
- public void Dispose()
- {
- if (assetsBundle!=null)
- {
- assetsBundle.Unload(false);
- assetsBundle = null;
- }
- assetsName = string.Empty;
- for (int i = 0; i < depAssetsList.Count; i++)
- {
- depAssetsList[i].DelUseCount();
- }
- depAssetsList.Clear();
- isEmpty = true;
- }
- }
- }
|