IEnumerator Load(string sceneName, string resolution) { this.loading = true; if (this.resources is BundleResources) { BundleManager manager = (BundleManager)(this.resources as BundleResources).BundleManager; BundleManifest manifest = manager.BundleManifest; manifest.ActiveVariants = new string[] { "", resolution }; } ISceneLoadingResult <Scene> result = this.resources.LoadSceneAsync(sceneName); while (!result.IsDone) { Debug.LogFormat("Loading {0}%", (result.Progress * 100)); yield return(null); } this.loading = false; if (result.Exception != null) { Debug.LogFormat("Loads scene '{0}' failure.Error:{1}", sceneName, result.Exception); } else { Debug.LogFormat("Loads scene '{0}' completed.", sceneName); } }
public IEnumerator Init() { #if USE_5_BUNDLE //DependsConfigLoad load = new DependsConfigLoad(); //yield return load.Start(Path.Combine(AppSetting.ResourceUrl, "AndroidNew")); //mDependsConfig = load.GetConfig(); mDependsConfig = new BundleManifest(); mDependsConfig.LoadFile(Path.Combine(AppSetting.ResourcePath, "ReleaseManifest")); isInit = true; yield break; #else DependsConfigLoad load = new DependsConfigLoad(); yield return(load.Start(Path.Combine(AppSetting.ResourceUrl, "DependsData.release"))); mDependsConfig = load.GetConfig(); if (mDependsConfig == null) { Debug.Log("Depends Config is Empty!"); mDependsConfig = new List <ResourceDepends>(); } #endif Load(new string[] { "Shader" }, "Root", LoadRootResourcesComplete); }
public IProgressResult <float, List <BundleInfo> > GetDownloadList(BundleManifest manifest) { ProgressResult <float, List <BundleInfo> > result = new ProgressResult <float, List <BundleInfo> >(); Executors.RunOnCoroutine(DoAnalyzeDownloadList(result, manifest), result); return(result); }
public void BundleConfigReadsBundleConfigWithOnlyStyleBundles() { // Arrange var xml = ToStream( @"<?xml version=""1.0"" ?> <bundles version=""1.0""> <styleBundle path=""~/my-bundle-path"" cdnPath=""http://cdn.com/bundle.css""> <include path=""~/Content/jQuery.ui.css""></include> </styleBundle> <styleBundle path=""~/content/css""> <include path=""~/scripts/master.css""></include> <include path=""~/scripts/page.css""></include> </styleBundle> </bundles>"); // Act var result = BundleManifest.ReadBundleManifest(xml); // Assert Assert.AreEqual(0, result.ScriptBundles.Count); Assert.AreEqual(2, result.StyleBundles.Count); Assert.AreEqual("~/my-bundle-path", result.StyleBundles[0].Path); Assert.AreEqual("http://cdn.com/bundle.css", result.StyleBundles[0].CdnPath); Assert.AreEqual(1, result.StyleBundles[0].Includes.Count); Assert.AreEqual("~/Content/jQuery.ui.css", result.StyleBundles[0].Includes[0]); Assert.AreEqual("~/content/css", result.StyleBundles[1].Path); Assert.AreEqual(2, result.StyleBundles[1].Includes.Count); Assert.AreEqual("~/scripts/master.css", result.StyleBundles[1].Includes[0]); Assert.AreEqual("~/scripts/page.css", result.StyleBundles[1].Includes[1]); }
IResources GetResources() { if (this.resources != null) { return(this.resources); } /* Create a BundleManifestLoader. */ IBundleManifestLoader manifestLoader = new BundleManifestLoader(); /* Loads BundleManifest. */ BundleManifest manifest = manifestLoader.Load(BundleUtil.GetStorableDirectory() + BundleSetting.ManifestFilename); //manifest.ActiveVariants = new string[] { "", "sd" }; //manifest.ActiveVariants = new string[] { "", "hd" }; /* Create a PathInfoParser. */ IPathInfoParser pathInfoParser = new AutoMappingPathInfoParser(manifest); /* Use a custom BundleLoaderBuilder */ ILoaderBuilder builder = new CustomBundleLoaderBuilder(new Uri(BundleUtil.GetReadOnlyDirectory()), false); /* Create a BundleManager */ IBundleManager manager = new BundleManager(manifest, builder); /* Create a BundleResources */ this.resources = new BundleResources(pathInfoParser, manager); return(this.resources); }
public static void PrepareBundleAssetsMap() { BundleManifest manifest = AssetDatabase.LoadAssetAtPath <BundleManifest>(manifestAssetPath); if (manifest == null) { manifest = ScriptableObject.CreateInstance <BundleManifest>(); AssetDatabase.CreateAsset(manifest, manifestAssetPath); } else { manifest.ClearBundleData(); } string[] bundleNames = AssetDatabase.GetAllAssetBundleNames(); foreach (string bundleName in bundleNames) { foreach (string assetName in AssetDatabase.GetAssetPathsFromAssetBundle(bundleName)) { manifest.AddBundleAssetPath(assetName, bundleName); } manifest.AddBundleData(bundleName, AssetDatabase.GetAssetBundleDependencies(bundleName, true)); } EditorUtility.SetDirty(manifest); AssetDatabase.LoadAssetAtPath <BundleManifest>(manifestAssetPath); AssetImporter importer = AssetImporter.GetAtPath(manifestAssetPath); importer.assetBundleName = manifestName; }
/// <summary> /// /// </summary> /// <param name="rootFolder">The AssetBundle directory.</param> /// <param name="manifest"></param> /// <param name="version"></param> /// <param name="defaultVariant"></param> /// <returns></returns> public virtual BundleManifest CreateBundleManifest(string rootFolder, AssetBundleManifest manifest, string version, string defaultVariant = null) { if (manifest == null) { throw new System.ArgumentNullException("manifest"); } List <BundleInfo> bundles = new List <BundleInfo>(); /* Bundle list */ foreach (string bundleFullName in manifest.GetAllAssetBundles()) { BundleInfo bundle = CreateBundleInfo(rootFolder, bundleFullName, manifest); if (bundle == null) { continue; } bundles.Add(bundle); } BundleManifest bundleManifest = new BundleManifest(bundles, version, null); this.CheckAssetBundle(bundleManifest); return(bundleManifest); }
public virtual List <BundleInfo> GetDeltaUpdates(BundleManifest previousVersion, BundleManifest currentVersion, bool compareCRC = false) { List <BundleInfo> bundles = new List <BundleInfo>(); Dictionary <string, BundleInfo> dict = new Dictionary <string, BundleInfo>(); foreach (BundleInfo bundle in previousVersion.GetAll()) { dict.Add(bundle.FullName, bundle); } foreach (BundleInfo bundle in currentVersion.GetAll()) { BundleInfo previous; if (!dict.TryGetValue(bundle.FullName, out previous)) { bundles.Add(bundle); continue; } if (previous.Hash.Equals(bundle.Hash) && previous.Encoding.Equals(bundle.Encoding) && (!compareCRC || previous.CRC == bundle.CRC)) { continue; } bundles.Add(bundle); } return(bundles); }
public ScriptBundleManifestBuilder_Tests() { bundle = new ScriptBundle("~/path") { PageLocation = "body", Hash = new byte[] { 1, 2, 3 }, Processor = new ScriptPipeline() }; asset = new StubAsset { CreateStream = () => new MemoryStream(bundleContent), References = { new AssetReference("~/path/asset/file", asset, 0, AssetReferenceType.RawFilename) } }; bundle.Assets.Add(asset); bundle.AddReference("~/reference/path"); bundle.Process(new CassetteSettings("")); var urlModifier = Mock.Of <IUrlModifier>(); bundle.Renderer = new ConstantHtmlRenderer <ScriptBundle>("", urlModifier); manifest = builder.BuildManifest(bundle); }
public IEnumerator Download(List <string> bundleNames) { this.downloading = true; try { IProgressResult <Progress, BundleManifest> manifestResult = this.downloader.DownloadManifest(BundleSetting.ManifestFilename); yield return(manifestResult.WaitForDone()); if (manifestResult.Exception != null) { Debug.LogFormat("Downloads BundleManifest failure.Error:{0}", manifestResult.Exception); yield break; } BundleManifest manifest = manifestResult.Result; IProgressResult <float, List <BundleInfo> > bundlesResult = this.downloader.GetDownloadList(manifest); yield return(bundlesResult.WaitForDone()); List <BundleInfo> bundles = bundlesResult.Result.FindAll(obj => bundleNames.Contains(obj.FullName)); if (bundles == null || bundles.Count <= 0) { Debug.LogFormat("Please clear cache and remove StreamingAssets,try again."); yield break; } IProgressResult <Progress, bool> downloadResult = this.downloader.DownloadBundles(bundles); downloadResult.Callbackable().OnProgressCallback(p => { Debug.LogFormat("Downloading {0:F2}KB/{1:F2}KB {2:F3}KB/S", p.GetCompletedSize(UNIT.KB), p.GetTotalSize(UNIT.KB), p.GetSpeed(UNIT.KB)); }); yield return(downloadResult.WaitForDone()); if (downloadResult.Exception != null) { Debug.LogFormat("Downloads AssetBundle failure.Error:{0}", downloadResult.Exception); yield break; } if (this.resources != null) { //update BundleManager's manifest BundleManager manager = (this.resources as BundleResources).BundleManager as BundleManager; manager.BundleManifest = manifest; } #if UNITY_EDITOR UnityEditor.EditorUtility.OpenWithDefaultApp(BundleUtil.GetReadOnlyDirectory()); #endif } finally { this.downloading = false; } }
public static void BuildAssetBundles(string outputFile, ref List <AssetBundleBuild> allBundle, BuildAssetBundleOptions options = BuildAssetBundleOptions.None) { if (Directory.Exists(outputFile) == false) { Directory.CreateDirectory(outputFile); } var beforManifest = TryLoadBeforBundleManifest(outputFile); var nowManigest = BuildPipeline.BuildAssetBundles(outputFile, allBundle.ToArray(), BuildAssetBundleOptions.None, BundleSetting.UnityBuildTarget); if (nowManigest != null && beforManifest != null) { var finalManifest = BundleManifest.CombineBundleManifest(outputFile, beforManifest, nowManigest); if (finalManifest != null) { finalManifest.SaveToFile(outputFile + "/ReleaseManifest"); } else { Logged.LogColor("ff0000", string.Format("BundleManifest.CombineBundleManifest result is null!")); } } else { var finalManifest = new BundleManifest(nowManigest); finalManifest.SaveToFile(outputFile + "/ReleaseManifest"); } Debug.Log(outputFile); }
private string GetDesignTimeHtml() { string bundlePath = MapPath(Site, BundleManifest.BundleManifestPath); if (String.IsNullOrEmpty(bundlePath)) { return(null); } BundleManifest bundleManfiest; using (var stream = File.OpenRead(bundlePath)) { bundleManfiest = BundleManifest.ReadBundleManifest(stream); } var bundle = bundleManfiest.StyleBundles.FirstOrDefault(b => b.Path.Equals(Path, StringComparison.OrdinalIgnoreCase)); if (bundle != null) { var builder = new StringBuilder(); foreach (var item in bundle.Includes.Select(ResolveClientUrl)) { builder.AppendFormat(@"<link href=""{0}"" rel=""stylesheet""/>", item); } return(builder.ToString()); } return(null); }
public void BundleConfigReadsBundleConfigWithOnlyScriptBundles() { // Arrange var xml = ToStream( @"<?xml version=""1.0"" ?> <bundles version=""1.0""> <scriptBundle path=""~/my-bundle-path"" cdnPath=""http://cdn.com/bundle.js"" cdnFallbackExpression=""!window.jquery""> <include path=""~/Scripts/jQuery.js""></include> </scriptBundle> <scriptBundle path=""~/Scripts/js""> <include path=""~/scripts/first.js""></include> <include path=""~/scripts/second.js""></include> </scriptBundle> </bundles>"); // Act var result = BundleManifest.ReadBundleManifest(xml); // Assert Assert.AreEqual(0, result.StyleBundles.Count); Assert.AreEqual(2, result.ScriptBundles.Count); Assert.AreEqual("~/my-bundle-path", result.ScriptBundles[0].Path); Assert.AreEqual("http://cdn.com/bundle.js", result.ScriptBundles[0].CdnPath); Assert.AreEqual("!window.jquery", result.ScriptBundles[0].CdnFallbackExpression); Assert.AreEqual(1, result.ScriptBundles[0].Includes.Count); Assert.AreEqual("~/Scripts/jQuery.js", result.ScriptBundles[0].Includes[0]); Assert.AreEqual("~/Scripts/js", result.ScriptBundles[1].Path); Assert.AreEqual(2, result.ScriptBundles[1].Includes.Count); Assert.AreEqual("~/scripts/first.js", result.ScriptBundles[1].Includes[0]); Assert.AreEqual("~/scripts/second.js", result.ScriptBundles[1].Includes[1]); }
public MigrationContext( MigrationSettings settings, OrmPackage package, PortalApplication portal, BundleManifest manifest, IVSProject vsProject, CodeDomProvider codeProvider, StrongNameKeyPair keyPair, IExtendedLog log, IOperationStatus status, ICollection<Plugin> plugins) { _settings = settings; _package = package; _portal = portal; _manifest = manifest; _vsProject = vsProject; _codeProvider = codeProvider; _keyPair = keyPair; _log = log; _status = status; _plugins = plugins; _forms = new Dictionary<string, FormInfo>(StringComparer.InvariantCultureIgnoreCase); _mainViews = new Dictionary<string, MainViewInfo>(StringComparer.InvariantCultureIgnoreCase); _navigation = new List<NavigationInfo>(); _scripts = new Dictionary<string, ScriptInfo>(StringComparer.InvariantCultureIgnoreCase); _tables = new Dictionary<string, TableInfo>(StringComparer.InvariantCultureIgnoreCase); _entities = new Dictionary<string, OrmEntity>(StringComparer.InvariantCultureIgnoreCase); _relationships = new Dictionary<DataPathJoin, RelationshipInfo>(); _linkedFiles = new List<LinkedFile>(); _localizedStrings = new Dictionary<string, string>(StringComparer.InvariantCultureIgnoreCase); _references = new Dictionary<string, string>(StringComparer.InvariantCultureIgnoreCase); _smartParts = new List<SmartPartMapping>(); _secondaryJoins = new Dictionary<DataPathJoin, DataPathJoin>(); }
/// <summary> /// Check the loop reference. /// </summary> /// <param name="bundleManifest">Bundle manifest.</param> protected virtual void CheckAssetBundle(BundleManifest bundleManifest) { BundleInfo[] bundles = bundleManifest.GetAll(); foreach (BundleInfo bundle in bundles) { bundleManifest.GetDependencies(bundle.Name, true); } }
/// <summary> /// Helper function to mount a base bundle /// </summary> /// <param name="p_Superbundle">Superbundle to get bundles from</param> /// <param name="p_BundleEntry">The bundle entry information</param> /// <param name="p_BaseReader">The reader of the base file</param> /// <param name="p_PatchReader">The reader of the patch file</param> /// <returns>Loaded BundleBase object</returns> private BundleBase MountBundle(SuperbundleBase p_Superbundle, BundleEntry p_BundleEntry, RimeReader p_BaseReader, RimeReader p_PatchReader) { p_BaseReader.Seek(p_BundleEntry.Offset, SeekOrigin.Begin); var s_Manifest = new BundleManifest(p_BaseReader, p_BundleEntry); var s_Bundle = s_Manifest.RealManifest.Bundle; p_Superbundle.Bundles.TryAdd(p_BundleEntry.ID, s_Bundle); return(s_Bundle); }
public virtual BundleManifest GetPreviousBundleManifest(string outputPath, BuildTarget buildTarget, string version) { FileInfo file = this.GetPreviousBundleManifestFile(outputPath, buildTarget, version); if (file == null) { return(null); } var json = File.ReadAllText(file.FullName); return(BundleManifest.Parse(json)); }
IResources CreateResources() { IResources resources = null; #if UNITY_EDITOR if (SimulationSetting.IsSimulationMode) { Debug.Log("Use SimulationResources. Run In Editor"); /* Create a PathInfoParser. */ //IPathInfoParser pathInfoParser = new SimplePathInfoParser("@"); IPathInfoParser pathInfoParser = new SimulationAutoMappingPathInfoParser(); /* Create a BundleManager */ IBundleManager manager = new SimulationBundleManager(); /* Create a BundleResources */ resources = new SimulationResources(pathInfoParser, manager); } else #endif { /* Create a BundleManifestLoader. */ IBundleManifestLoader manifestLoader = new BundleManifestLoader(); /* Loads BundleManifest. */ BundleManifest manifest = manifestLoader.Load(BundleUtil.GetReadOnlyDirectory() + BundleSetting.ManifestFilename); //manifest.ActiveVariants = new string[] { "", "sd" }; manifest.ActiveVariants = new string[] { "", "hd" }; /* Create a PathInfoParser. */ //IPathInfoParser pathInfoParser = new SimplePathInfoParser("@"); IPathInfoParser pathInfoParser = new AutoMappingPathInfoParser(manifest); /* Create a BundleLoaderBuilder */ //ILoaderBuilder builder = new WWWBundleLoaderBuilder(new Uri(BundleUtil.GetReadOnlyDirectory()), false); /* AES128_CBC_PKCS7 */ //RijndaelCryptograph rijndaelCryptograph = new RijndaelCryptograph(128, Encoding.ASCII.GetBytes(this.key), Encoding.ASCII.GetBytes(this.iv)); IStreamDecryptor decryptor = CryptographUtil.GetDecryptor(Algorithm.AES128_CBC_PKCS7, Encoding.ASCII.GetBytes(this.key), Encoding.ASCII.GetBytes(this.iv)); /* Use a custom BundleLoaderBuilder */ ILoaderBuilder builder = new CustomBundleLoaderBuilder(new Uri(BundleUtil.GetReadOnlyDirectory()), false, decryptor); /* Create a BundleManager */ IBundleManager manager = new BundleManager(manifest, builder); /* Create a BundleResources */ resources = new BundleResources(pathInfoParser, manager); } return(resources); }
/// <summary> /// Bundle constructor from BundleManifest /// </summary> /// <param name="p_Manifest">Bundle manifest</param> /// <param name="p_Reader">Opened reader to the start to the</param> /// <param name="p_Entry">Bundle Entry Information</param> public Bundle(BundleManifest p_Manifest, RimeReader p_Reader, BundleEntry p_Entry) { Entry = p_Entry; Path = p_Entry.ID; if (p_Manifest.RealManifest.EbxMode) { ParseEbxBundle(p_Manifest, p_Reader); } else { ParseDbxBundle(p_Manifest, p_Reader); } }
public XAssetBundleManifest(BundleManifest manifest) { mDict_AssetBundleInfos = new Dictionary <string, AssetBundleInfo>(); foreach (var item in manifest.assetBundleInfos) { if (!mDict_AssetBundleInfos.ContainsKey(item.name)) { mDict_AssetBundleInfos.Add(item.name, item); } else { mDict_AssetBundleInfos[item.name] = item; } } }
public void BundleConfigReadsBundleDataCorrectly() { // Arrange var xml = ToStream(@"<?xml version=""1.0"" ?><bundles version=""1.0""><styleBundle path=""~/my-bundle-path""><include path=""~/Content/jQuery.css""></include><include path=""~/Content/jQuery.ui.css""></include></styleBundle></bundles>"); // Act var result = BundleManifest.ReadBundleManifest(xml); // Assert Assert.AreEqual(1, result.StyleBundles.Count); Assert.AreEqual("~/my-bundle-path", result.StyleBundles[0].Path); Assert.AreEqual(2, result.StyleBundles[0].Includes.Count); Assert.AreEqual("~/Content/jQuery.css", result.StyleBundles[0].Includes[0]); Assert.AreEqual("~/Content/jQuery.ui.css", result.StyleBundles[0].Includes[1]); }
public virtual BundleManifest CopyAssetBundle(BundleManifest manifest, DirectoryInfo src, DirectoryInfo dest, List <IBundleModifier> bundleModifierChain = null, IBundleFilter bundleFilter = null) { if (!src.Exists) { throw new DirectoryNotFoundException(string.Format("Not found the directory '{0}'.", src.FullName)); } try { foreach (BundleInfo bundleInfo in manifest.GetAll()) { if (bundleFilter != null && !bundleFilter.IsValid(bundleInfo)) { continue; } FileInfo srcFile = new FileInfo(System.IO.Path.Combine(src.FullName, bundleInfo.Filename).Replace(@"\", "/")); byte[] data = File.ReadAllBytes(srcFile.FullName); BundleData bundleData = new BundleData(bundleInfo, data); if (bundleModifierChain != null && bundleModifierChain.Count > 0) { foreach (IBundleModifier modifier in bundleModifierChain) { modifier.Modify(bundleData); } } FileInfo destFile = new FileInfo(System.IO.Path.Combine(dest.FullName, bundleInfo.Filename).Replace(@"\", "/")); if (destFile.Exists) { destFile.Delete(); } if (!destFile.Directory.Exists) { destFile.Directory.Create(); } File.WriteAllBytes(destFile.FullName, bundleData.Data); } return(manifest); } catch (System.Exception e) { throw new System.Exception(string.Format("Copy AssetBundles failure from {0} to {1}.", src.FullName, dest.FullName), e); } }
/// <summary> /// Create a new PebbleBundle from a .pwb file and parse its metadata. /// </summary> /// <param name="path">The relative or full path to the file.</param> public PebbleBundle(string path) { Stream jsonStream; FullPath = Path.GetFullPath(path); _Bundle = ZipFile.Read(FullPath); if (_Bundle.ContainsEntry("manifest.json")) { jsonStream = _Bundle["manifest.json"].OpenReader(); } else { throw new ArgumentException("manifest.json not found in archive - not a Pebble bundle."); } var serializer = new DataContractJsonSerializer(typeof(BundleManifest)); _Manifest = (BundleManifest)serializer.ReadObject(jsonStream); jsonStream.Close(); HasResources = (_Manifest.Resources.Size != 0); if (_Manifest.Type == "firmware") { BundleType = BundleTypes.Firmware; } else { BundleType = BundleTypes.Application; Stream binStream; if (_Bundle.ContainsEntry(_Manifest.Application.Filename)) { binStream = _Bundle[_Manifest.Application.Filename].OpenReader(); } else { throw new Exception(string.Format("App file {0} not found in archive", _Manifest.Application.Filename)); } AppMetadata = Util.ReadStruct <ApplicationMetadata>(binStream); binStream.Close(); } _Bundle.Dispose(); }
/// <summary> /// Create a new PebbleBundle from a .pwb file and parse its metadata. /// </summary> /// <param name="path">The relative or full path to the file.</param> public PebbleBundle(String path) { Stream jsonstream; FullPath = Path.GetFullPath(path); Bundle = ZipFile.Read(FullPath); if (Bundle.ContainsEntry("manifest.json")) { jsonstream = Bundle["manifest.json"].OpenReader(); } else { throw new ArgumentException("manifest.json not found in archive - not a Pebble bundle."); } var serializer = new DataContractJsonSerializer(typeof(BundleManifest)); Manifest = serializer.ReadObject(jsonstream) as BundleManifest; jsonstream.Close(); HasResources = (Manifest.Resources.Size != 0); if (Manifest.Type == "firmware") { BundleType = BundleTypes.Firmware; } else { BundleType = BundleTypes.Application; if (!Bundle.ContainsEntry(Manifest.Application.Filename)) { String format = "App file {0} not found in archive"; throw new ArgumentException(String.Format(format, Manifest.Application.Filename)); } Binary = ReadBinary(Manifest.Application.Filename); Application = Util.ReadStruct <ApplicationMetadata>(Binary); if (HasResources) { ResourcesBinary = ReadBinary(Manifest.Resources.Filename); } } }
/// <summary> /// Create a new PebbleBundle from a .pwb file and parse its metadata. /// </summary> /// <param name="path">The relative or full path to the file.</param> public PebbleBundle(String path) { Stream jsonstream; Stream binstream; FullPath = Path.GetFullPath(path); Bundle = ZipFile.Read(FullPath); if (Bundle.ContainsEntry("manifest.json")) { jsonstream = Bundle["manifest.json"].OpenReader(); } else { throw new ArgumentException("manifest.json not found in archive - not a Pebble bundle."); } var serializer = new DataContractJsonSerializer(typeof(BundleManifest)); Manifest = serializer.ReadObject(jsonstream) as BundleManifest; jsonstream.Close(); HasResources = (Manifest.Resources.Size != 0); if (Manifest.Type == "firmware") { BundleType = BundleTypes.Firmware; } else { BundleType = BundleTypes.Application; if (Bundle.ContainsEntry(Manifest.Application.Filename)) { binstream = Bundle[Manifest.Application.Filename].OpenReader(); } else { String format = "App file {0} not found in archive"; throw new ArgumentException(String.Format(format, Manifest.Application.Filename)); } Application = Util.ReadStruct<ApplicationMetadata>(binstream); binstream.Close(); } }
public virtual List <BundleManifest> FindBundleManifests(string outputPath, BuildTarget buildTarget) { List <BundleManifest> bundles = new List <BundleManifest>(); List <FileInfo> files = this.FindBundleManifestFiles(outputPath, buildTarget); if (files.Count == 0) { return(bundles); } for (int i = 0; i < files.Count; i++) { var info = files[i]; var json = File.ReadAllText(info.FullName); bundles.Add(BundleManifest.Parse(json)); } return(bundles); }
public IEnumerator LoadGame(string name) { if (!gamesMap.ContainsKey(name)) { Debug.Log("load game not found: " + name); yield break; } #if UNITY_EDITOR if (SimulationSetting.IsSimulationMode) { var ret = simulator.LoadBundle(name + "lua"); yield return(ret.WaitForDone()); yield break; } #endif Debug.Log("enter LoadGame " + name); var cfg = gamesMap[name]; IBundleManifestLoader manifestLoader = new BundleManifestLoader(); var path = BundleUtil.GetStorableDirectory() + name + "/"; var mani = path + BundleSetting.ManifestFilename; BundleManifest manifest = manifestLoader.Load(mani); IPathInfoParser pathInfoParser = new AutoMappingPathInfoParser(manifest); ILoaderBuilder builder = new CustomBundleLoaderBuilder(new Uri(path), false); IBundleManager manager = new BundleManager(manifest, builder); var rc = new BundleResources(pathInfoParser, manager); cfg.resources = rc; var result = rc.LoadBundle(name + "lua"); yield return(result.WaitForDone()); cfg.luaBundle = result.Result as DefaultBundle; Debug.Log("leave LoadGame " + name); }
IResources CreateResources(BundleManifest manifest) { IResources resources = null; #if UNITY_EDITOR if (SimulationSetting.IsSimulationMode) { Debug.Log("Use SimulationResources. Run In Editor"); /* Create a PathInfoParser. */ //IPathInfoParser pathInfoParser = new SimplePathInfoParser("@"); IPathInfoParser pathInfoParser = new SimulationAutoMappingPathInfoParser(); /* Create a BundleManager */ IBundleManager manager = new SimulationBundleManager(); /* Create a BundleResources */ resources = new SimulationResources(pathInfoParser, manager); } else #endif { /* Create a PathInfoParser. */ //IPathInfoParser pathInfoParser = new SimplePathInfoParser("@"); IPathInfoParser pathInfoParser = new AutoMappingPathInfoParser(manifest); /* Create a BundleLoaderBuilder */ //ILoaderBuilder builder = new WWWBundleLoaderBuilder(new Uri(BundleUtil.GetReadOnlyDirectory()), false); /* AES128_CBC_PKCS7 */ RijndaelCryptograph rijndaelCryptograph = new RijndaelCryptograph(128, Encoding.ASCII.GetBytes(this.key), Encoding.ASCII.GetBytes(this.iv)); /* Use a custom BundleLoaderBuilder */ ILoaderBuilder builder = new CustomBundleLoaderBuilder(new Uri(BundleUtil.GetReadOnlyDirectory()), false, rijndaelCryptograph); /* Create a BundleManager */ IBundleManager manager = new BundleManager(manifest, builder); /* Create a BundleResources */ resources = new BundleResources(pathInfoParser, manager); } return(resources); }
void Awake() { /* Create a BundleManifestLoader. */ IBundleManifestLoader manifestLoader = new BundleManifestLoader(); /* Loads BundleManifest. */ BundleManifest manifest = manifestLoader.Load(BundleUtil.GetReadOnlyDirectory() + BundleSetting.ManifestFilename); /* Create a PathInfoParser. */ IPathInfoParser pathInfoParser = new AutoMappingPathInfoParser(manifest); /* Use a BundleLoaderBuilder */ ILoaderBuilder builder = new CustomBundleLoaderBuilder(new Uri(BundleUtil.GetReadOnlyDirectory()), false, new RijndaelCryptograph(128, Encoding.ASCII.GetBytes(key), Encoding.ASCII.GetBytes(iv))); /* Create a BundleManager */ IBundleManager manager = new BundleManager(manifest, builder); /* Create a BundleResources */ resources = new BundleResources(pathInfoParser, manager); }
IResources GetResources() { if (resources != null) { return(resources); } IBundleManifestLoader manifestLoader = new BundleManifestLoader(); BundleManifest manifest = manifestLoader.Load(uriString + BundleSetting.ManifestFilename); IPathInfoParser pathInfoParser = new AutoMappingPathInfoParser(manifest); ILoaderBuilder builder = new Loxodon.Framework.Examples.Bundle.CustomBundleLoaderBuilder(new Uri(uriString), false, new RijndaelCryptograph(128, Encoding.ASCII.GetBytes(key), Encoding.ASCII.GetBytes(iv))); IBundleManager manager = new BundleManager(manifest, builder); resources = new BundleResources(pathInfoParser, manager); return(resources); }
IEnumerator Start() { ApplicationContext context = Context.GetApplicationContext(); /* Create a BundleManifestLoader. */ IBundleManifestLoader manifestLoader = new BundleManifestLoader(); /* Loads BundleManifest. */ IAsyncResult <BundleManifest> result = manifestLoader.LoadAsync(BundleUtil.GetReadOnlyDirectory() + BundleSetting.ManifestFilename); yield return(result.WaitForDone()); BundleManifest manifest = result.Result; //manifest.ActiveVariants = new string[] { "", "sd" }; manifest.ActiveVariants = new string[] { "", "hd" }; this.resources = CreateResources(manifest); context.GetContainer().Register <IResources>(this.resources); }
public Dictionary <string, BundleManifest> CreateBundleManifests(string rootFolder, AssetBundleManifest manifest, string version) { if (manifest == null) { throw new System.ArgumentNullException("manifest"); } var bundlesMap = new Dictionary <string, List <BundleInfo> > (); foreach (string bundleFullName in manifest.GetAllAssetBundles()) { BundleInfo bundle = CreateBundleInfo(rootFolder, bundleFullName, manifest); if (bundle == null) { continue; } var assets = bundle.Assets; var ss = assets [0].Split('/'); var game = ss[2]; if (!bundlesMap.ContainsKey(game)) { bundlesMap.Add(game, new List <BundleInfo>()); } var bs = bundlesMap[game]; bs.Add(bundle); } var bdmap = new Dictionary <string, BundleManifest> (); foreach (var item in bundlesMap) { var bundleManifest = new BundleManifest(item.Value, version, null); CheckAssetBundle(bundleManifest); bdmap.Add(item.Key, bundleManifest); } return(bdmap); }
public static void BuildAssetBundles(string outputFile, ref List<AssetBundleBuild> allBundle, BuildAssetBundleOptions options = BuildAssetBundleOptions.None) { if (Directory.Exists(outputFile) == false) Directory.CreateDirectory(outputFile); var beforManifest = TryLoadBeforBundleManifest(outputFile); var nowManigest = BuildPipeline.BuildAssetBundles(outputFile, allBundle.ToArray(), BuildAssetBundleOptions.None, BundleSetting.UnityBuildTarget); if (nowManigest != null && beforManifest != null) { var finalManifest = BundleManifest.CombineBundleManifest(outputFile, beforManifest, nowManigest); if (finalManifest != null) { finalManifest.SaveToFile(outputFile + "/ReleaseManifest"); } else { Logged.LogColor("ff0000", string.Format("BundleManifest.CombineBundleManifest result is null!")); } } else { var finalManifest = new BundleManifest(nowManigest); finalManifest.SaveToFile(outputFile + "/ReleaseManifest"); } Debug.Log(outputFile); }
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; }
private BundleManifest GetBundle() { _BundleModel model = _projectContext.ActiveProject.Models.Get<_BundleModel>(); BundleManifest manifest = CollectionUtils.Find( model.BundleManifests, delegate(BundleManifest item) { return (StringUtils.CaseInsensitiveEquals(item.Name, _settings.ManifestName)); }); if (manifest == null) { manifest = new BundleManifest(model); manifest.Name = _settings.ManifestName; manifest.AutoAddChildren = false; manifest.Validate(); manifest.Save(); model.BundleManifests.Add(manifest); _hierarchyNodeService.InsertBundleManifestNode(manifest); } return manifest; }