public override T DoLoad <T>(string strBundleName, string strPath_With_ExtensionName, bool bNotLoad_IsError) { if (_mapLoadedBundle.ContainsKey(strBundleName) == false) { if (bNotLoad_IsError) { Debug.LogError($"{_pOwner.name} Bundle Is Not Loaded! {strBundleName}", _pOwner); return(null); } else { string strBundlePath = GetBundlePath(strBundleName); var pBundleNew = AssetBundle.LoadFromFile(strBundlePath); if (pBundleNew == null) { Debug.LogError($"{_pOwner.name} Failed to load AssetBundle! {strBundleName}", _pOwner); return(null); } BundleWrapper pBundleWrapper = new BundleWrapper(strBundleName, null); pBundleWrapper.DoSetBundle(pBundleNew); _mapLoadedBundle.Add(strBundleName, pBundleWrapper); } } if (strPath_With_ExtensionName.Contains("/")) { int iCutIndex = strPath_With_ExtensionName.LastIndexOf("/"); strPath_With_ExtensionName = strPath_With_ExtensionName.Substring(iCutIndex + 1, strPath_With_ExtensionName.Length - iCutIndex - 1); } var pBundle = _mapLoadedBundle[strBundleName].pBundle; T pObject = pBundle.LoadAsset <T>(strPath_With_ExtensionName); if (pObject == null) { if (bNotLoad_IsError) { Debug.LogError($"{_pOwner.name} Streaming Asset LoadFail Bundle : {strBundleName} File Name : {strPath_With_ExtensionName}", _pOwner); } return(null); } return(pObject); }
public override IEnumerator PreLoadBundle_Coroutine(string strBundleName, delOnLoadBundle OnLoadBundle) { bool bLoaded = false; if (_mapLoadedBundle.ContainsKey(strBundleName)) { var pAsyncExist = _mapLoadedBundle[strBundleName].pAsyncOperation; if (pAsyncExist.isDone) { OnLoadBundle(strBundleName, true); yield break; } else { // yield return pAsyncExist; 다른 코루틴에서 같은 yield 탄다고 에러 뱉음 while (pAsyncExist.isDone == false) { yield return(null); } bLoaded = true; } } if (bLoaded == false) { var pAsync = AssetBundle.LoadFromFileAsync(GetBundlePath(strBundleName)); BundleWrapper pBundleWrapper = new BundleWrapper(strBundleName, pAsync); _mapLoadedBundle.Add(strBundleName, pBundleWrapper); yield return(pAsync); pBundleWrapper.DoSetBundle(pAsync.assetBundle); } bool bResult = _mapLoadedBundle[strBundleName].pBundle != null; if (bResult == false) { Debug.LogError($"{_pOwner.name} PreLoadBundle Fail - {strBundleName}", _pOwner); } OnLoadBundle(strBundleName, bResult); }