public int AddAssetBundleName(string name, string[] depends, out AssetDataPackage package) { package = null; if (string.IsNullOrEmpty(name)) { return(-1); } string key = null; string path = null; GetPackageKeyFromABName(name, out key, out path); if (string.IsNullOrEmpty(key)) { return(-1); } package = GetAssetDataPackage(key); if (package == null) { package = new AssetDataPackage(key, path, System.DateTime.Now.Ticks); m_AllAssetDataPackages.Add(package); Log.i("#Create Config Group:" + key); } return(package.AddAssetBundleName(name, depends)); }
public void LoadPackageFromFile(string path) { if (string.IsNullOrEmpty(path)) { return; } object data = SerializeHelper.DeserializeBinary(FileMgr.Instance.OpenReadStream(path)); if (data == null) { Log.e("Failed Deserialize AssetDataTable:" + path); return; } AssetDataPackage.SerializeData sd = data as AssetDataPackage.SerializeData; if (sd == null) { Log.e("Failed Load AssetDataTable:" + path); return; } //string parentFolder = PathHelper.GetFolderPath(path); AssetDataPackage package = BuildAssetDataPackage(sd, path); string key = package.key; for (int i = m_AllAssetDataPackages.Count - 1; i >= 0; --i) { if (m_AllAssetDataPackages[i].key.Equals(key)) { var oldConfig = m_AllAssetDataPackages[i]; if (oldConfig.buildTime > package.buildTime) { return; } else { m_AllAssetDataPackages.RemoveAt(i); break; } } } m_AllAssetDataPackages.Add(package); }
private static void ProcessAssetBundleRes(AssetDataTable table) { AssetDataPackage group = null; int abIndex = table.AddAssetBundleName(ProjectPathConfigTemp.ABMANIFEST_AB_NAME, null, out group); if (abIndex > 0) { group.AddAssetData(new AssetData(ProjectPathConfigTemp.ABMANIFEST_ASSET_NAME, eResType.kABAsset, abIndex)); } AssetDatabase.RemoveUnusedAssetBundleNames(); string[] abNames = AssetDatabase.GetAllAssetBundleNames(); if (abNames != null && abNames.Length > 0) { for (int i = 0; i < abNames.Length; ++i) { string[] depends = AssetDatabase.GetAssetBundleDependencies(abNames[i], false); abIndex = table.AddAssetBundleName(abNames[i], depends, out group); if (abIndex < 0) { continue; } string[] assets = AssetDatabase.GetAssetPathsFromAssetBundle(abNames[i]); foreach (var cell in assets) { if (cell.EndsWith(".unity")) { group.AddAssetData(new AssetData(AssetPath2Name(cell), eResType.kABScene, abIndex)); } else { group.AddAssetData(new AssetData(AssetPath2Name(cell), eResType.kABAsset, abIndex)); } } } } table.Dump(); }
public void SwitchLanguage(string key) { m_ActiveAssetDataPackages.Clear(); string languageKey = string.Format("[{0}]", key); for (int i = m_AllAssetDataPackages.Count - 1; i >= 0; --i) { AssetDataPackage group = m_AllAssetDataPackages[i]; if (!group.key.Contains("i18res")) { m_ActiveAssetDataPackages.Add(group); } else if (group.key.Contains(languageKey)) { m_ActiveAssetDataPackages.Add(group); } } Log.i("AssetDataTable Switch 2 Language:" + key); }