/// <summary> /// 添加一个节点到头部 /// </summary> /// <returns>DoubleLinkedListNode</returns> public DoubleLinkedListNode <T> AddToHeader(T t) { DoubleLinkedListNode <T> node = _doubleLinkNodePool.Spawn(true); node.prev = node.next = null; node.curr = t; return(AddToHeader(node)); }
/// <summary> /// 加载单个assetbundle根据名字 /// </summary> /// <returns>AssetBundle</returns> private AssetBundle LoadAssetBundle(string name) { AssetBundleItem item = null; uint crc = CRC32.GetCRC32(name); if (!_assetBundleItemDic.TryGetValue(crc, out item)) { AssetBundle assetBundle = null; string fullPath = Application.streamingAssetsPath + "/" + name; if (File.Exists(fullPath)) { assetBundle = AssetBundle.LoadFromFile(fullPath); } if (assetBundle == null) { Debug.LogError("Load AssetBundle Error Path:" + fullPath); } item = _assetBundleItemPool.Spawn(true); item.assetbundle = assetBundle; item.refCount++; _assetBundleItemDic.Add(crc, item); } else { item.refCount++; } return(item.assetbundle); }
/// <summary> /// 异步加载资源,仅仅是不需要实例化的资源,例如音频,图片等等 /// </summary> public void AsyncLoadResource(string path, OnAsyncObjFinish dealFinish, LoadResPriority priority, uint crc = 0, object param1 = null, object param2 = null, object param3 = null) { if (crc == 0) { crc = CRC32.GetCRC32(path); } ResourceItem item = GetCancheResourceItem(crc); if (item != null) { if (dealFinish != null) { dealFinish(path, item._obj, param1, param2, param3); } return; } //判断是否在加载中 AsyncLoadResParam param = null; if (!_loadingAssetDic.TryGetValue(crc, out param) || param == null) { param = _asyncLoadResParamPool.Spawn(true); param.crc = crc; param.path = path; param.priority = priority; _loadingAssetDic.Add(crc, param); _loadingAssetList[(int)priority].Add(param); } //往回调列表里面加回调 AsyncCallBack callBack = _asyncCallBackPool.Spawn(true); callBack.dealFinish = dealFinish; callBack.param1 = param1; callBack.param2 = param2; callBack.param3 = param3; param.callBackList.Add(callBack); }