/// <summary> /// /// </summary> /// <param name="list"></param> public virtual void exportAllPrefab(List <ExportRootVO> list) { clearCache(); //Unity5Packer Packer.RebuildAtlasCacheIfNeeded(buildTarget, true, Packer.Execution.Normal); List <ExportPrefabRefVO> prefabPathList = new List <ExportPrefabRefVO>(); foreach (ExportRootVO exportPrefabItemVo in list) { foreach (string exportPrefabFromPath in exportPrefabItemVo.from) { List <string> tempList = FileHelper.FindFile(exportPrefabFromPath, exportPrefabItemVo.extentions); foreach (string item in tempList) { ExportPrefabRefVO prefabRefVo = new ExportPrefabRefVO(); prefabRefVo.path = item.Replace(Application.dataPath, "Assets"); prefabRefVo.exportRootVo = exportPrefabItemVo; prefabPathList.Add(prefabRefVo); } } } exprotPrefabs(prefabPathList); }
//private ExportSceneAssetsRefVO _currentProcessSceneAssets; protected List <AssetBundleBuild> collectionPrefab(ExportPrefabRefVO exportPrefabRefVO) { string prefabPath = exportPrefabRefVO.path; string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(prefabPath).Trim(); fileNameWithoutExtension = fileNameFormat(fileNameWithoutExtension); string fileExtension = Path.GetExtension(prefabPath).ToLower(); //是否是个scene场景; bool isScene = (fileExtension == ".unity"); /*_currentProcessSceneAssets = null; * if (isScene) * { * if (allScenesAssetsDic.TryGetValue(prefabPath, out _currentProcessSceneAssets) == false) * { * _currentProcessSceneAssets = new ExportSceneAssetsRefVO(fileNameWithoutExtension); * _currentProcessSceneAssets.exportPrefabRefVO = exportPrefabRefVO; * allScenesAssetsDic.Add(prefabPath, _currentProcessSceneAssets); * } * }*/ string[] depends = GetDependencies(prefabPath); toRemovesSet.Clear(); //收集嵌套的prefab; getInnerPrefabDepend(prefabPath, depends, toRemovesSet); List <AssetBundleBuild> builds = new List <AssetBundleBuild>(); foreach (string depend in depends) { if (toRemovesSet.Contains(depend)) { continue; } string extension = Path.GetExtension(depend).ToLower(); switch (extension) { case ".jpg": case ".png": case ".psd": case ".tif": case ".dds": case ".tga": case ".ttf": case ".cubemap": addDepend(BITMAPS, depend, prefabPath); break; case ".wav": case ".mp3": case ".mp4": case ".ogg": addDepend(SOUNDS, depend, prefabPath); break; case ".exr": //独立掉这个会丢失lightmap break; case ".shader": addDepend(SHADERS, depend, prefabPath); break; case ".mat": ///材质只加入到通用列表里面(区分一个包名,两个打包项的同名同路径在unity里面认为是同一个文件) addDepend(MATERIALS, depend, prefabPath); break; case ".dll": case ".cs": break; case ".obj": if (isScene == false) { addDepend(OBJS, depend, prefabPath); } break; case ".fbx": if (isScene == false) { addDepend(FBXS, depend, prefabPath); } break; case ".anim": addDepend(ANIMS, depend, prefabPath); break; case ".playable": addDepend(PLAYABLES, depend, prefabPath); break; case ".controller": addDepend(CONTROLLERS, depend, prefabPath); break; case ".asset": break; case ".prefab": case ".unity": //不用加进去; //addDepend(PREFABS, depend, prefabPath); break; default: break; } } string fileName = fileNameWithoutExtension + PathDefine.U3D; string folder = exportPrefabRefVO.exportRootVo.name; if (string.IsNullOrEmpty(folder) == false) { fileName = folder + "/" + fileName; } AssetBundleBuild build = new AssetBundleBuild(); build.assetBundleName = fileName; build.assetNames = new string[] { prefabPath }; builds.Add(build); assetBundleReferences.Add(prefabPath, build); return(builds); }