/// <summary> /// 清楚单个预制体,会刷新资源数据库 /// 配置表 /// </summary> /// <param name="patch"></param> public static void ClearSinglePrefab(string patch) { string lowerPatch = patch; List <string> dependeciesList = new List <string>(AssetDatabase.GetDependencies(new string[] { patch })); //引用的资源,无非就几种:代码,贴图,材质球,动画控制器,动画Mask,动画clip,fbx //我们只将贴图、fbx、动画控制器、动画clip打包,其他的直接整合到prefab的包里面 foreach (string s in dependeciesList) { string lowerString = s; if (IsFBXAsset(s)) { if (!lowerString.Contains(ArtitsPatch) && !lowerString.Contains(SceneOptimitzedConfigPatch)) { Debug.LogError("预制体:" + patch + "引用了Artist以外的资源,请修!:" + s); continue; } if (lowerString.Contains(SceneAssetPatch)) { if (!lowerString.Contains(AssetBundleManager.ArtistCommonPatch)) { Debug.LogError("预制体请不要引用场景资源下的东西,如果要引用,请放到Artist/CommonArtist文件夹下!:" + patch + ",引用路径:" + s); continue; } } if (lowerString.Contains(ArtistDebugPatch)) { Debug.LogError("预制体请不要引用资源调试目录下的东西:" + patch + ",引用路径:" + s); continue; } ClearAssetBundleData(AssetImporter.GetAtPath(s)); } else if (IsTextureAsset(s)) { //如果引用了字体资源,跳过,字体资源不需要加载,常驻内存的 if (lowerString.Contains(FontPatch)) { continue; } if (!lowerString.Contains(ArtitsPatch) && !lowerString.Contains(SceneOptimitzedConfigPatch)) { Debug.LogError("预制体:" + patch + "引用了Artist以外的资源,请修!:" + s); continue; } if (lowerString.Contains(SceneAssetPatch)) { if (!lowerString.Contains(AssetBundleManager.ArtistCommonPatch)) { Debug.LogError("预制体请不要引用场景资源下的东西,如果要引用,请放到Artist/CommonArtist文件夹下!:" + patch + ",引用路径:" + s); continue; } } if (lowerString.Contains(ArtistDebugPatch)) { Debug.LogError("预制体请不要引用资源调试目录下的东西:" + patch + ",引用路径:" + s); continue; } ClearAssetBundleData(AssetImporter.GetAtPath(s)); } else if (IsControllerAsset(s)) { if (lowerString.Contains(SceneAssetPatch)) { if (!lowerString.Contains(AssetBundleManager.ArtistCommonPatch)) { Debug.LogError("预制体请不要引用场景资源下的东西,如果要引用,请放到Artist/CommonArtist文件夹下!:" + patch + ",引用路径:" + s); continue; } } if (lowerString.Contains(ArtistDebugPatch)) { Debug.LogError("预制体请不要引用资源调试目录下的东西:" + patch + ",引用路径:" + s); continue; } ClearAssetBundleData(AssetImporter.GetAtPath(s)); } //只有特效会用这个clip else if (IsAniClipAsset(s)) { if (lowerString.Contains(SceneAssetPatch)) { if (!lowerString.Contains(AssetBundleManager.ArtistCommonPatch)) { Debug.LogError("预制体请不要引用场景资源下的东西,如果要引用,请放到Artist/CommonArtist文件夹下!:" + patch + ",引用路径:" + s); continue; } } if (lowerString.Contains(ArtistDebugPatch)) { Debug.LogError("预制体请不要引用资源调试目录下的东西:" + patch + ",引用路径:" + s); continue; } ClearAssetBundleData(AssetImporter.GetAtPath(s)); } else if (IsMaterialAsset(s)) { //如果引用了字体资源,跳过,字体资源不需要加载,常驻内存的 if (lowerString.Contains(FontPatch)) { continue; } if (!lowerString.Contains(ArtitsPatch) && !lowerString.Contains(SceneOptimitzedConfigPatch)) { Debug.LogError("预制体:" + patch + "引用了Artist的资源,请修!:" + s); continue; } if (lowerString.Contains(SceneAssetPatch)) { if (!lowerString.Contains(AssetBundleManager.ArtistCommonPatch)) { Debug.LogError("预制体请不要引用场景资源下的东西,如果要引用,请放到Artist/CommonArtist文件夹下!:" + patch + ",引用路径:" + s); continue; } } if (lowerString.Contains(ArtistDebugPatch)) { Debug.LogError("预制体请不要引用资源调试目录下的东西:" + patch + ",引用路径:" + s); continue; } ClearAssetBundleData(AssetImporter.GetAtPath(s)); } else if (IsPrefabAssets(s) && !lowerString.Equals(lowerPatch)) { if (!lowerString.Contains(AssetBundleManager.PrefabCommonPatch)) { Debug.LogError("不能引用预制体,如果要引用,请使用动态加载!" + lowerPatch + ",引用路径:" + lowerString); continue; } } } AssetBundleManager.DeletePrefabConfig(AssetDatabase.AssetPathToGUID(patch)); }