public static void SaveAssetCache(BuildTarget buildTarget, ABAssetDataList cache) { var data = LitJson.JsonMapper.ToJson(cache); var path = X2AssetsBundleEditor.PreOutPath(buildTarget); using (Stream file = File.Create(path + "/AssetDatas.json")) { var bytes = System.Text.Encoding.UTF8.GetBytes(data); file.Write(bytes, 0, bytes.Length); file.Close(); } }
public static ABAssetDataList ReloadCache(BuildTarget buildTarget) { string data = ""; var path = X2AssetsBundleEditor.PreOutPath(buildTarget); using (StreamReader file = File.OpenText(path + "/AssetDatas.json")) { data = file.ReadToEnd(); } ABAssetDataList cache = LitJson.JsonMapper.ToObject <ABAssetDataList>(data); return(cache); }
private static ABAssetInfo ColloectDependecies_Report(string prefabPath, string fileName = "") { prefabPath = prefabPath.ToLower(); string[] depends = AssetDatabase.GetDependencies(prefabPath, false); if (prefabPath.EndsWith(".unity")) { if (fileName.Contains(".")) { fileName = fileName.Substring(0, fileName.IndexOf(".")); } } ABAssetInfo parentAssetInfo = null; if (!m_dependsDic.ContainsKey(prefabPath)) { parentAssetInfo = X2AssetsBundleEditor.LoadAssetData(prefabPath); m_dependsDic.Add(prefabPath, parentAssetInfo); if (depends != null) { for (int i = 0; i < depends.Length; i++) { depends[i] = depends[i].ToLower().Replace("\\", "/"); if (!depends[i].EndsWith("dll") && !depends[i].EndsWith("cs") && !depends[i].EndsWith("js")) { var childAssetInfo = ColloectDependecies_Report(depends[i]); parentAssetInfo.AddChild(childAssetInfo); } } } } else { parentAssetInfo = m_dependsDic[prefabPath]; } return(parentAssetInfo); }