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