/// <summary> /// 清理应用的AssetBundle Id。 /// </summary> public static void CleanAllAssetBundleId() { var assetPaths = new List <string>(); var databasePaths = IOUtility.GetPathsContainSonDir( ProjectInfoDati.GetActualInstance().ProjectAssetDatabaseDir); assetPaths.AddRange(databasePaths); foreach (var assetPath in assetPaths) { if (!SelectPath(assetPath)) { continue; } var assetsPath = UnityIOUtility.GetAssetsPath(assetPath); var importer = AssetImporter.GetAtPath(assetsPath); if (importer == null) { continue; } importer.assetBundleName = null; } AssetDatabase.RemoveUnusedAssetBundleNames(); Debug.Log("AssetBundle包Id已清空!"); }
public static void BuildAssetInfos() { //var currentApp = YuU3dAppSettingDati.CurrentActual; var assetInfos = new Dictionary <char, Dictionary <string, AssetInfo> >(); var hotDir = ProjectInfoDati.GetActualInstance().ProjectAssetDatabaseDir; var hotPaths = IOUtility.GetPathsContainSonDir(hotDir, SelectAssetPath); foreach (var hotPath in hotPaths) { var assetId = Path.GetFileNameWithoutExtension(hotPath).ToLower(); var suffix = Path.GetExtension(hotPath); if (_sameIds.Contains(assetId)) { Debug.LogError($"发现命名重复的资源{assetId}!"); continue; } try { _sameIds.Add(assetId); var dirPath = hotPath.Replace(hotDir, ""); var lastIndex = dirPath.LastIndexOf('/'); if (lastIndex != -1) { dirPath = dirPath.Substring(0, lastIndex).EnsureDirEnd(); } var info = new AssetInfo(assetId, dirPath, AssetLocation.HotUpdate, suffix); var cIndex = assetId[0]; if (!assetInfos.ContainsKey(cIndex)) { assetInfos.Add(cIndex, new Dictionary <string, AssetInfo>()); } assetInfos[cIndex].Add(assetId, info); } catch (Exception e) { Debug.LogError(e.Message); } } var writePath = $"{Application.streamingAssetsPath}/{ProjectInfoDati.GetActualInstance().DevelopProjectName}/Config/AssetInfo.byte"; SerializeUtility.SerializeAndWriteTo(assetInfos, writePath); Debug.Log("资源数据创建完毕!"); AssetDatabase.Refresh(); }