public override int[] LoadAssets(string[] paths, LoadAssetCallback callback, LoadAssetCallback singleCallback, object userdata = null) { if (paths == null || paths.Length == 0) { return(null); } int length = paths.Length; int[] refCounts = new int[length]; List <string> errorList = new List <string>(); LoadResult lr = new LoadResult(); lr.assets = new UnityEngine.Object[length]; lr.assetNames = new string[length]; lr.userData = userdata; int sign = 0; for (int i = 0; i < length; i++) { // Resources 读取暂时一律按照1处理 refCounts[i] = 1; string originPath = paths[i]; string path = GetNameWithoutExtension(originPath); GameLogger.DebugLog(LOG_CHANNEL.ASSET, "Load Asset " + path); ResourceRequest rr = Resources.LoadAsync(path); rr.completed += (AsyncOperation ao) => { sign++; int currentIndex = sign - 1; bool isSuccess = ao.isDone; GameLogger.DebugLog(LOG_CHANNEL.ASSET, string.Format("Asset: [{0}] Loaded, Success: [{1}]", originPath, isSuccess)); if (lr.isSuccess) { lr.isSuccess = isSuccess; } if (!isSuccess) { errorList.Add(originPath); } else { lr.assets[currentIndex] = rr.asset; lr.assetNames[currentIndex] = originPath; if (ResourceCallBack != null) { ResourceCallBack.Invoke(lr); } } LoadResult lrSingle = new LoadResult(); lrSingle.isSuccess = isSuccess; lrSingle.assets = new UnityEngine.Object[1] { rr.asset }; lrSingle.assetNames = new string[1] { originPath }; lrSingle.userData = userdata; if (singleCallback != null) { singleCallback.Invoke(lrSingle); } if (sign == length) { lr.errorAssetNames = errorList.ToArray(); if (callback != null) { callback.Invoke(lr); } } }; } return(refCounts); }