static public int GetDirectDependencies(IntPtr l) { try { #if DEBUG var method = System.Reflection.MethodBase.GetCurrentMethod(); string methodName = GetMethodName(method); #if UNITY_5_5_OR_NEWER UnityEngine.Profiling.Profiler.BeginSample(methodName); #else Profiler.BeginSample(methodName); #endif #endif UnityEngine.AssetBundleManifest self = (UnityEngine.AssetBundleManifest)checkSelf(l); System.String a1; checkType(l, 2, out a1); var ret = self.GetDirectDependencies(a1); pushValue(l, true); pushValue(l, ret); return(2); } catch (Exception e) { return(error(l, e)); } #if DEBUG finally { #if UNITY_5_5_OR_NEWER UnityEngine.Profiling.Profiler.EndSample(); #else Profiler.EndSample(); #endif } #endif }
private void ApplyManifest(AssetBundleManifest manifest) { string[] allbundleNames = manifest.GetAllAssetBundles(); for (int i = 0; i < allbundleNames.Length; i++) { string name = allbundleNames[i]; string[] depends = manifest.GetDirectDependencies(allbundleNames[i]); mManifest.Add(name, depends); } }
static public int GetDirectDependencies(IntPtr l) { try { UnityEngine.AssetBundleManifest self = (UnityEngine.AssetBundleManifest)checkSelf(l); System.String a1; checkType(l, 2, out a1); var ret = self.GetDirectDependencies(a1); pushValue(l, ret); return(1); } catch (Exception e) { return(error(l, e)); } }
private static void CreateModOutputCfg(ModuleBuilder mb, CreateAssetBundlesContext ctx, UnityEngine.AssetBundleManifest manifest) { var outputRootDir = ctx.outputRootDir; var targetDir = System.IO.Path.Combine(outputRootDir, "out", mb.Cfg.Name); System.IO.Directory.CreateDirectory(targetDir); // copy bundle files foreach (var bb in mb.bundleBuilders) { var bName = bb.BundleName; var srcFileName = System.IO.Path.Combine(outputRootDir, bName); var dstFileName = System.IO.Path.Combine(targetDir, bName); System.IO.File.Copy(srcFileName, dstFileName); } // generate cfg json file var mcfg = new ModOutputCfg(); mcfg.name = mb.Cfg.Name; mcfg.version = mb.version; mcfg.csVer = ctx.csVersion; mcfg.lobbyVer = ctx.lobbyVersion; var bcfgList = new List <ModBundleOutputCfg>(); foreach (var bb in mb.bundleBuilders) { var bName = bb.BundleName; var srcFileName = System.IO.Path.Combine(outputRootDir, bName); var bcfg = new ModBundleOutputCfg(); bcfg.name = bName; var bytes = System.IO.File.ReadAllBytes(srcFileName); bcfg.md5 = NetHelper.MD5(bytes); bcfg.size = bytes.Length; bcfg.deps = manifest.GetDirectDependencies(bName); bcfgList.Add(bcfg); } mcfg.abList = bcfgList.ToArray(); var cfgFileName = System.IO.Path.Combine(targetDir, "cfg.json"); var json = UnityEngine.JsonUtility.ToJson(mcfg, true); System.IO.File.WriteAllText(cfgFileName, json); }
static int GetDirectDependencies(IntPtr L) { try { ToLua.CheckArgsCount(L, 2); UnityEngine.AssetBundleManifest obj = (UnityEngine.AssetBundleManifest)ToLua.CheckObject <UnityEngine.AssetBundleManifest>(L, 1); string arg0 = ToLua.CheckString(L, 2); string[] o = obj.GetDirectDependencies(arg0); ToLua.Push(L, o); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
static bool PatchPrefix(IEasyBundle __instance, string key, string rootPath, UnityEngine.AssetBundleManifest manifest, IBundleLock bundleLock) { EasyBundleHelper esayBundle = new EasyBundleHelper(__instance); esayBundle.Key = key; var path = rootPath + key; BundleInfo bundle; if (Settings.bundles.TryGetValue(key, out bundle)) { path = bundle.Path; } esayBundle.Path = path; esayBundle.KeyWithoutExtension = Path.GetFileNameWithoutExtension(key); string[] dependencyKeys = manifest.GetDirectDependencies(key); foreach (KeyValuePair <string, BundleInfo> kvp in Settings.bundles) { if (!key.Equals(kvp.Key)) { continue; } List <string> result = dependencyKeys == null ? new List <string>() : dependencyKeys.ToList <string>(); dependencyKeys = result.Union(kvp.Value.DependencyKeys).ToList <string>().ToArray <string>(); break; } esayBundle.DependencyKeys = dependencyKeys; esayBundle.LoadState = new BindableState(ELoadState.Unloaded, null); esayBundle.BundleLock = bundleLock; return(false); }
static AssetBundleManifest OutputResult(string resultFile, float useTime, UnityEngine.AssetBundleManifest manifest) { if (manifest == null) { return(null); } AssetBundleManifest result = new AssetBundleManifest(); result.buildTime = useTime; List <AssetBundleManifest.AssetBundleBuild> bundles = new List <AssetBundleManifest.AssetBundleBuild>(); foreach (var name in manifest.GetAllAssetBundles()) { AssetBundleManifest.AssetBundleBuild bundle = new AssetBundleManifest.AssetBundleBuild(); bundle.assetBundleName = name; bundle.dependency = manifest.GetDirectDependencies(name); bundle.hash = manifest.GetAssetBundleHash(name).ToString(); bundles.Add(bundle); } result.builds = bundles.ToArray(); File.WriteAllText(resultFile, JsonUtility.ToJson(result, true)); return(result); }
public static BundleManifest CombineBundleManifest(string outputPath,AssetBundleManifest beforManifest, AssetBundleManifest nowManifest) { BundleManifest data = new BundleManifest(beforManifest); // remove non exist List<string> removeList = new List<string>(); foreach (var iter in data.mManifest) { if (File.Exists(outputPath + "/" + iter.Key) == false) { removeList.Add(iter.Key); } } for (int i = 0; i < removeList.Count; i++) { data.mManifest.Remove(removeList[i]); } string nowManifestName = string.Empty; string[] allNowManifest = nowManifest.GetAllAssetBundles(); for (int i = 0; i < allNowManifest.Length; i++) { nowManifestName = allNowManifest[i]; string[] nowDepend = nowManifest.GetDirectDependencies(nowManifestName); if (data.mManifest.ContainsKey(nowManifestName)) { data.mManifest[nowManifestName] = nowDepend; } else { data.mManifest.Add(nowManifestName, nowDepend); } } return data; }