public void AddAssetbundleAssetsCache(string assetbundleName, string postfix = null) { #if UNITY_EDITOR if (AssetBundleConfig.IsEditorMode) { return; } #endif if (!IsAssetBundleLoaded(assetbundleName)) { Logger.LogError("Try to add assets cache from unloaded assetbundle : " + assetbundleName); return; } var curAssetbundle = GetAssetBundleCache(assetbundleName); var allAssetNames = assetsPathMapping.GetAllAssetNames(assetbundleName); for (int i = 0; i < allAssetNames.Count; i++) { var assetName = allAssetNames[i]; if (IsAssetLoaded(assetName)) { continue; } if (!string.IsNullOrEmpty(postfix) && !assetName.EndsWith(postfix)) { continue; } var assetPath = AssetBundleUtility.PackagePathToAssetsPath(assetName); var asset = curAssetbundle == null ? null : curAssetbundle.LoadAsset(assetPath); AddAssetCache(assetName, asset); #if UNITY_EDITOR // 说明:在Editor模拟时,Shader要重新指定 var go = asset as GameObject; if (go != null) { var renderers = go.GetComponentsInChildren<Renderer>(); for (int j = 0; j < renderers.Length; j++) { var mat = renderers[j].sharedMaterial; if (mat == null) { continue; } var shader = mat.shader; if (shader != null) { var shaderName = shader.name; mat.shader = Shader.Find(shaderName); } } } #endif } }
public void AddAssetbundleAssetsCache(string assetbundleName) { #if UNITY_EDITOR // if (AssetBundleConfig.IsEditorMode) // { // return; // } #endif if (!IsAssetBundleLoaded(assetbundleName)) { Logger.LogError("Try to add assets cache from unloaded assetbundle : " + assetbundleName); return; } var curAssetbundle = GetAssetBundleCache(assetbundleName); if (curAssetbundle.isStreamedSceneAssetBundle) { // LoadScene(assetbundleName, curAssetbundle); return; } var allAssetNames = assetsPathMapping.GetAllAssetNames(assetbundleName); if (allAssetNames.Count == 0) { allAssetNames = idpAssetsPathMapping.GetAllAssetNames(assetbundleName); } for (int i = 0; i < allAssetNames.Count; i++) { var assetName = allAssetNames[i]; if (IsAssetLoaded(assetName)) { continue; } var assetPath = AssetBundleUtility.PackagePathToAssetsPath(assetName); UnityEngine.Object asset = null; asset = curAssetbundle == null ? null : curAssetbundle.LoadAsset(assetPath); AddAssetCache(assetName, asset); var go = asset as GameObject; if (go != null) { #if UNITY_EDITOR ResetEditorShader(go); // 说明:在Editor模拟时,Shader要重新指定 #endif //多语言转换 TranslateAsset(go); ResetPostProcess(go); } } }
public List <string> GetAssetNameList(string assetbundleName) { return(assetsPathMapping.GetAllAssetNames(assetbundleName)); }