// 卸载 public void unload() { ob = null; obs = null; if (status == XLoadStatus.LOADING || status == XLoadStatus.NONE) { status = XLoadStatus.FAIL; } XAssetKey key = new XAssetKey { res = res, all = all, tp = tp }; // 一般情况下都是属于bundle的,另外Editor模式是属于别的 if (bundle == null) { XLoad.instance.unloadAssetInfoFromCache(key); } else { // 属于bundle的 bundle.unloadAssetInfo(key); } }
public bool unloadAssetInfoFromCache(XAssetKey key) { if (assets.ContainsKey(key)) { assets.Remove(key); return(true); } return(false); }
public XAssetInfo getAssetInfoFromCache(XAssetKey key, XLoadStatus status) { if (assets.ContainsKey(key)) { return(assets[key]); } XAssetInfo value = new XAssetInfo { res = key.res, all = key.all, tp = key.tp, status = status }; assets[key] = value; return(value); }
// 获取一个依赖包的资源 public XAssetInfo getAssetInfo(XAssetKey key) { if (assets.ContainsKey(key)) { return(assets[key]); } XAssetInfo value = new XAssetInfo { res = key.res, all = key.all, tp = key.tp, status = XLoadStatus.NONE, bundle = this }; assets[key] = value; return(value); }
public bool unloadAssetInfo(XAssetKey key) { if (assets.ContainsKey(key)) { assets.Remove(key); if (assets.Count == 0) { // 计时需要释放,说明曾经unload过,如果一次没有,那么不允许释放 lastAssetsEmpty = Time.realtimeSinceStartup; } return(true); } return(false); }
public XAssetInfo getAssetInfo(XLoadRes res) { // 如果有了则直接返回 if (res.asset != null) { return(res.asset); } XAssetKey key = new XAssetKey { res = res.res, all = res.all, tp = res.tp }; if (string.IsNullOrEmpty(res.res)) { res.asset = getAssetInfoFromCache(key, XLoadStatus.FAIL); return(res.asset); } // 从AB里面获取一个 if (isLoadFromAB) { // 从AB包里面获取 XBundleInfo info = getAssetBundle(res.res); if (info != null) { // 是否一定要在这里取?--1方便info做引用计数 res.asset = info.getAssetInfo(key); } else { res.asset = getAssetInfoFromCache(key, XLoadStatus.FAIL); } } else { // 直接在上面在上面进行装载 res.asset = getAssetInfoFromCache(key, XLoadStatus.NONE); } return(res.asset); }