protected void Application_Start() { AreaRegistration.RegisterAllAreas(); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); //BundleConfig.RegisterBundles(BundleTable.Bundles); BundleManager.Config(); //MVC控制器工厂添加IOC容器 var container = ContainerUnity.GetContainer(); ControllerBuilder.Current.SetControllerFactory(new ControllerFactory(container)); //注入所有控制器 container.RegisterControllers(Assembly.GetExecutingAssembly()); //注入DbContext container.Register <DbContext>(Lifetime.Scoped); //easyui验证绑定 SettingsBindManager.RegisterBinder("validatebox", new ValidateBoxSettingBinder()); SettingsBindManager.RegisterBinder("numberbox", new NumberBoxSettingBinder()); //使用 LightEntity 反序列化转换器 GlobalSetting.Converters.Add(new LightEntityJsonConverter()); //从 Container 里反转类型反序列化 GlobalSetting.Converters.Add(new ContainerJsonConverter(container)); //注册实体持久化的订阅通知 //DefaultSubscribeManager.Instance.AddSubscriber<PersistentSubject>(subject => new EntitySubscriber().Accept(subject)); MapperUnity.AddProfile <AutoProfile>(); }
public void Ensure_Order_Correct() { var a1 = new List <CssFile> { new CssFile("/css/test1.css"), new CssFile("/css/test3.css"), new CssFile("/css/test2.css"), new CssFile("/css/test4.css") { Priority = 1 }, new CssFile("/css/test5.css") }; BundleManager.CreateCssBundle("Css1", a1.ToArray()); var bundle = BundleManager.GetCssBundles().First(); Assert.AreEqual(a1[3], (CssFile)bundle.Value.First()); var currentIndex = -1; //iterate except for the one with the priority foreach (CssFile b in bundle.Value.Except(new[] { (CssFile)a1[3] })) { var newIndex = a1.IndexOf(b); Assert.Greater(newIndex, currentIndex); currentIndex = newIndex; } }
void newDefBundleTo(string parent, bool sceneBundle) { // Find a new bundle name string defBundleName = "EmptyBundle"; string currentBundleName = defBundleName; int index = 0; while (BundleManager.GetBundleData(currentBundleName) != null) { currentBundleName = defBundleName + (++index); } bool created = BundleManager.CreateNewBundle(currentBundleName, parent, sceneBundle); if (created) { if (IsFold(parent)) { SetFold(parent, false); } m_Selections.Clear(); m_Selections.Add(currentBundleName); } StartEditBundleName(currentBundleName); }
public static void RegisterBundles() { BundleManager.CreateCssBundle("Bootstrap", new CssFile("~/Content/css/site.css") ); BundleManager.CreateJsBundle("jquery", 1, new JavascriptFile("~/Scripts/lib/jquery/jquery-1.10.2.js"), new JavascriptFile("~/Scripts/lib/jquery/jquery.validate.js"), new JavascriptFile("~/Scripts/lib/jquery/jquery.validate.unobtrusive.bootstrap.js"), new JavascriptFile("~/Scripts/lib/jquery/jquery.hotkeys.js") ); BundleManager.CreateJsBundle("bootstrap", 3, new JavascriptFile("~/Scripts/lib/bootstrap/modernizr-2.6.2.js"), new JavascriptFile("~/Scripts/lib/bootstrap/bootstrap.min.js"), new JavascriptFile("~/Scripts/lib/bootstrap/respond.min.js"), new JavascriptFile("~/Scripts/lib/moment/moment-with-locales.min.js") ); BundleManager.CreateJsBundle("angular", 2, new JavascriptFile("~/Scripts/lib/anuglar/angular.js"), new JavascriptFile("~/Scripts/lib/anuglar/angular-animate.js"), new JavascriptFile("~/Scripts/lib/anuglar/angular-sanitize.js") ); BundleManager.CreateJsBundle("core", 4, new JavascriptFile("~/Scripts/lib/angular-ui/ui-bootstrap.js"), new JavascriptFile("~/Scripts/application.js") ); }
static Texture2D GetSharedIconOfInlucde(string assetPath) { var bundleList = BundleManager.GetRelatedBundles(assetPath); if (bundleList != null && bundleList.Count > 0) { foreach (BundleData bundle in bundleList) { if (bundle.name == currentBundle.name) { continue; } if (BundleManager.IsBundleDependOn(bundle.name, currentBundle.name)) { return(BMGUIStyles.GetIcon("dependedAsset")); } else if (BundleManager.IsBundleDependOn(currentBundle.name, bundle.name)) { return(BMGUIStyles.GetIcon("sharedAsset")); } } } bundleList = BundleManager.GetIncludeBundles(assetPath); if (bundleList != null && bundleList.Count > 1) { return(BMGUIStyles.GetIcon("duplicatedInclude")); } return(null); }
public GameObject Construct(AssetReference assetRef, BundleAssetLoadingInfo bundleInfo) { var asset = BundleManager.LoadAssetFromBundle(bundleInfo, bundleInfo.SpriteName); if (asset.GetType() == typeof(Texture2D)) { // "Type checking ew" // You're thinking it, I can tell. // Through all the horrible things we've done with this project, // type checking is where you draw the line? var tex = asset as Texture2D; if (tex != null) { Sprite sprite = Sprite.Create(tex, new Rect(0, 0, tex.width, tex.height), new Vector2(0.5f, 0.5f), 128f); return(CreateCardGameObject(assetRef, sprite)); } return(null); } else { var gameObject = asset as GameObject; if (gameObject != null) { GameObject.DontDestroyOnLoad(gameObject); return(gameObject); } } Trainworks.Log(BepInEx.Logging.LogLevel.Warning, "Invalid asset type " + asset.GetType() + " when loading asset: " + bundleInfo.SpriteName); return(null); }
// 以下方法是build script调用 public static void CreateAllBundlesFromCommand() { BundleManager.RemoveAllBundles(); // 删除InterpretedOutputPath下的文件 CleanOldBundles(); // 删除AssetBundle文件 CleanCacheBundles(); // CreateUIViewBundle(); CreateEquipBundle(); CreateAudioBundle(); // CreateLevelBundle(); CreatePlayerBundle(); CreateMonsterBundle(); CreateConfigBundle(); CreateSkillBundle(); CreateBigTexBundle(); CreateAiBundle(); CreateChildView(); CreateBigItemTex(); // CreateHeadIcons(); CreateNewbie(); CreateTavernTex(); BuildHelper.BuildAll(); BuildHelper.ExportBundleDataFileToOutput(); BuildHelper.ExportBundleBuildDataFileToOutput(); BuildHelper.ExportBMConfigerFileToOutput(); }
// Use this for initialization void Start() { updater = BundleManager.GetInstance(); updater.LoadFromWWW(remoteAddress); updater.OnAllUpdated += OnFinishUpdated; }
internal static void AddBundleToBuildList(string bundleName, ref Dictionary <string, List <string> > buildingRoutes) { BundleData bundle = BundleManager.GetBundleData(bundleName); var state = BundleManager.GetBuildStateOfBundle(bundleName); if (bundle == null) { Debug.LogError("Cannot find bundle " + bundleName); return; } //if( BuildHelper.IsBundleNeedBunild(bundle) ) if (state.changed) { string rootName = BundleManager.GetRootOf(bundle.name); if (buildingRoutes.ContainsKey(rootName)) { if (!buildingRoutes[rootName].Contains(bundle.name)) { buildingRoutes[rootName].Add(bundle.name); } else { Debug.LogError("Bundle name duplicated: " + bundle.name); } } else { List <string> buildingList = new List <string>(); buildingList.Add(bundle.name); buildingRoutes.Add(rootName, buildingList); } } }
public string GetPath(int id, EResourceType type) { string url = ""; switch (type) { case EResourceType.Effect: { Tab_Effect data = TableManager.GetEffectByID(id, 0); if (data == null) { LogModule.ErrorLog("GetPath called type {0} id {1} is invalid!", type, id); return(url); } url = data.Path.Substring(data.Path.LastIndexOf('/') + 1); url = BundleManager.GetBundleLoadUrl(BundleManager.PathEffectPrefab, url + ".data"); return(url); } case EResourceType.CharacterModel: { Tab_CharModel model = TableManager.GetCharModelByID(id, 0); if (model == null) { LogModule.ErrorLog("GetPath called type {0} id {1} is invalid!", type, id); return(url); } url = BundleManager.GetBundleLoadUrl(BundleManager.PathModelPrefab, model.ResPath + ".data"); return(url); } } LogModule.ErrorLog("GetPath failed invalid type {0} id {1} !", type, id); return("ffff"); }
private static void CreateBundle(string bunlePath, string parentName) { Object[] assetObjects = Resources.LoadAll(bunlePath); foreach (var asset in assetObjects) { string bundleName = asset.name; if (BundleManager.GetBundleData(bundleName) != null) { continue; } bool created = BundleManager.CreateNewBundle(bundleName, parentName, false); if (!created) { UnityEngine.Debug.LogError("Can't create bundle tree bundle : " + bundleName); } string bundleAssetDataPath = AssetDatabase.GetAssetPath(asset); if (BundleManager.CanAddPathToBundle(bundleAssetDataPath, bundleName)) { BundleManager.AddPathToBundle(bundleAssetDataPath, bundleName); } } }
public static void ProcessBuildState(bool save) { string platform = ""; #if UNITY_IPHONE platform = "ios"; #else platform = "android"; #endif string buildState_LastVersion = string.Format("Assets/_ThirdParty/BundleManager/LastVersion/{0}/BuildStates.txt", platform); string buildstate = "Assets/_ThirdParty/BundleManager/BuildStates.txt"; string bundleShipInfo_LastVersion = string.Format("Assets/_ThirdParty/BundleManager/LastVersion/{0}/BundleShipInfo.json", platform); string bundleShipInfo = "Assets/_ThirdParty/BundleManager/BundleShipInfo.json"; if (!save) { System.IO.File.Delete(buildstate); System.IO.File.Delete(bundleShipInfo); System.IO.File.Copy(buildState_LastVersion, buildstate); System.IO.File.Copy(bundleShipInfo_LastVersion, bundleShipInfo); BundleManager.RefreshAll(); } else { System.IO.File.Delete(buildState_LastVersion); System.IO.File.Delete(bundleShipInfo_LastVersion); System.IO.File.Copy(buildstate, buildState_LastVersion); System.IO.File.Copy(bundleShipInfo, bundleShipInfo_LastVersion); } AssetDatabase.Refresh(); }
public void Can_Add_And_Retreive_Js_Bundle() { var a1 = new[] { new JavascriptFile("/css/test1.css"), new JavascriptFile("/css/test2.css"), new JavascriptFile("/css/test3.css") }; var a2 = new[] { new JavascriptFile("/css/test4.css"), new JavascriptFile("/css/test5.css"), new JavascriptFile("/css/test6.css") }; var a3 = new[] { new JavascriptFile("/css/test7.css"), new JavascriptFile("/css/test8.css"), new JavascriptFile("/css/test9.css") }; BundleManager.CreateJsBundle("Js1", a1); BundleManager.CreateJsBundle("Js2", a2); BundleManager.CreateJsBundle("Js3", a2); Assert.AreEqual(BundleManager.GetJsBundles().Count, 3); }
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); //BundleConfig.RegisterBundles(BundleTable.Bundles); BundleManager.Config(); //MVC控制器工厂添加IOC容器 var container = GetContainer(); ControllerBuilder.Current.SetControllerFactory(new ControllerFactory(container)); //easyui验证绑定 SettingsBindManager.RegisterBinder("validatebox", new ValidateBoxSettingBinder()); SettingsBindManager.RegisterBinder("numberbox", new NumberBoxSettingBinder()); //使用 LightEntity 反序列化转换器 GlobalSetting.Converters.Add(new LightEntityJsonConverter()); //从 Container 里反转类型反序列化 GlobalSetting.Converters.Add(new ContainerJsonConverter(container)); //注册实体持久化的订阅通知 SubscribeManager.Register <EntityPersistentSubject>(new EntitySubscriber()); }
public override IEnumerator DownloadData() { yield return(StartCoroutine(data.GetAudio(1))); Debug.Log(data.audioBundle); AssetBundleLoadAssetOperation request = BundleManager.LoadAssetAsync(data.audioBundle[0], data.audioBundle[1], typeof(AudioClip)); if (request == null) { yield break; } yield return(StartCoroutine(request)); data.introAudio = request.GetAsset <AudioClip>(); request = BundleManager.LoadAssetAsync(data.audioBundle[2], data.audioBundle[3], typeof(AudioClip)); if (request == null) { yield break; } yield return(StartCoroutine(request)); data.detailAudio = request.GetAsset <AudioClip>(); BundleManager.UnloadBundle(data.audioBundle[0]); //Debug.Log(data.introAudio + " - " + data.detailAudio); }
bool GUI_TreeItem(int indent, string bundleName) { if (!m_CurrentShowingBundles.Contains(bundleName)) { m_CurrentShowingBundles.Add(bundleName); } BundleData bundleData = BundleManager.GetBundleData(bundleName); if (bundleData == null) { Debug.LogError("Cannot find bundle : " + bundleName); return(true); } Rect itemRect = GUI_DrawItem(bundleData, indent); EditProcess(itemRect, bundleData.name); if (DragProcess(itemRect, bundleData.name)) { return(false); } SelectProcess(itemRect, bundleData.name); if (m_CurrentEditing != bundleData.name) { RightClickMenu(itemRect); } return(GUI_DrawChildren(bundleData.name, indent)); }
private IEnumerator HashCodeLoad() { Debug.Log("copyFileEnd !!!!"); WWW versionLoader = new WWW(URLAntiCacheRandomizer.RandomURL(Baseurl + "/v.txt")); yield return(versionLoader); if (versionLoader.error == null && versionLoader.isDone) { string[] result = versionLoader.text.Split('\n'); foreach (string line in result) { if (line.Length > 0) { loadList.Add(line); } } //这里只是把服务器的v.txt列表传入后,和本地文件对比,如果名字不同或者版本不同。就做为下载文件 totalMtoLoad = BundleManager.getIns().TotalBytesToload(loadList); if (totalMtoLoad > 0) { NoticeUI.SetActive(true); } else { Debug.Log("检查文件正常,进入下一个scene"); StartCoroutine(LoadNextScene()); } } Debug.Log("totalMtoLoad=" + totalMtoLoad); }
protected override IEnumerator runTest() { string key = "embedded_asset_test"; TextAsset bundleTxt = Resources.Load <TextAsset>(key + ".unity3d"); AssetBundle bundle = AssetBundle.LoadFromMemory(bundleTxt.bytes); BundleManager manager = Content.BundleManager; BundleMount mount = manager.MountBundle(key, bundle); AsyncAssetBundleRequest <TextAsset> assetRequest = mount.LoadAsync <TextAsset>("embeddedasseta", "embeddedasseta.txt"); manager.UnmountBundle(key, unloadAllLoadedObjects: false); if (manager.IsMounted(key)) { IntegrationTest.Fail("Bundle should not be considered mounted while waiting to unmount."); } if (!manager.IsUnmounting(key)) { IntegrationTest.Fail("Bundle should be in the process of unmounting."); } yield return(assetRequest); if (assetRequest.Asset == null) { IntegrationTest.Fail("Failed to load asset"); } yield return(null); IntegrationTest.Assert(!manager.IsMounted(key)); IntegrationTest.Assert(!manager.IsUnmounting(key)); }
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; } }
internal static bool BuildBundleTree(BundleData bundle, List <string> requiredBuildList) { BuildPipeline.PushAssetDependencies(); bool succ = false; if (bundle.name.StartsWith("+")) { succ = true; EB.Debug.Log("Skip Folder Node {0}", bundle.name); } else { succ = BuildSingleBundle(bundle); if (!succ) { EB.Debug.LogError("{0} build failed.", bundle.name); BuildPipeline.PopAssetDependencies(); return(false); } else { EB.Debug.Log("{0} build succeed.", bundle.name); } } foreach (string childName in bundle.children) { BundleData child = BundleManager.GetBundleData(childName); if (child == null) { EB.Debug.LogError("Cannnot find bundle [{0}]. Sth wrong with the bundle config data.", childName); BuildPipeline.PopAssetDependencies(); return(false); } bool isDependingBundle = false; foreach (string requiredBundle in requiredBuildList) { if (BundleManager.IsBundleDependOn(requiredBundle, childName)) { isDependingBundle = true; break; } } if (isDependingBundle || !BuildConfiger.DeterministicBundle) { succ = BuildBundleTree(child, requiredBuildList); if (!succ) { BuildPipeline.PopAssetDependencies(); return(false); } } } BuildPipeline.PopAssetDependencies(); return(true); }
public static void CreateAssetBundlesFromSelection(UnityEngine.Object[] objects, string bundleParent) { if (objects == null || objects.Length == 0) { return; } float progress = 0.0f; foreach (UnityEngine.Object obj in objects) { string assetPath = AssetDatabase.GetAssetPath(obj); if (string.IsNullOrEmpty(assetPath)) { continue; } if (EditorUtility.DisplayCancelableProgressBar("Create AssetBundles from selection", string.Format("Adding {0} to bundle manager", assetPath), ++progress / objects.Length)) { EditorUtility.ClearProgressBar(); return; } string assetName = obj.name; if (BundleManager.GetBundleData(assetName) == null) { BundleManager.CreateNewBundle(assetName, bundleParent, false); } if (BundleManager.CanAddPathToBundle(assetPath, assetName)) { BundleManager.AddPathToBundle(assetPath, assetName); } } EditorUtility.ClearProgressBar(); }
protected override IEnumerator runTest() { string payload = $"embeddedasseta?dl=bundle:mock-create-bundle&b=embedded_asset_test&x=.txt"; ContentManifest.AssetEntry entry = ContentManifest.AssetEntry.Parse(payload); BundleManager bundleManager = new BundleManager(null); DeviceManager deviceManager = new DeviceManager(); deviceManager.Mount(new BundleDevice(deviceManager, bundleManager)); AssetRequest <TextAsset> requestA = deviceManager.LoadAsync <TextAsset>(entry.DeviceList, ref entry); AssetRequest <TextAsset> requestB = deviceManager.LoadAsync <TextAsset>(entry.DeviceList, ref entry); if (requestA == null || requestB == null) { IntegrationTest.Fail("requestA == null"); } else { yield return(requestA); yield return(requestB); IntegrationTestEx.FailIf(requestA.Asset == null); IntegrationTestEx.FailIf(requestB.Asset == null); IntegrationTest.Pass(); } bundleManager.UnmountAllBundles(); }
protected override void CreateBundle(string bundleName, List <BundleTagHelperItem> bundleItems) { BundleManager.CreateScriptBundle( bundleName, configuration => bundleItems.ForEach(bi => bi.AddToConfiguration(configuration)) ); }
private void EnsureMappingsExist() { if (xnaBundles == null && !Game.IsDummy) { string streamingAssetsPath; if (PlatformInstances.IsEditor) { streamingAssetsPath = string.Format("file://{0}/", Application.streamingAssetsPath); } else #if U_WINDOWS || U_PS4 { streamingAssetsPath = string.Format("file://{0}/", Application.streamingAssetsPath); } #else { streamingAssetsPath = string.Format("{0}/", Application.streamingAssetsPath); } #endif Log.WriteT("Initializing Mapped Content..."); xnaBundles = new BundleManager(streamingAssetsPath, new StringReader(UResources.Load <TextAsset>("AssetBundleMappings").text), true); streams = new StreamedContentManager(streamingAssetsPath, new StringReader(UResources.Load <TextAsset>("StreamedMappings").text)); Log.WriteT("Mapped Content Initialized"); } }
public static bool BundleLoadDictionary() { #if UNITY_EDITOR TextAsset txt = Resources.Load("Data/Localization", typeof(TextAsset)) as TextAsset; if (txt == null) { txt = BundleManager.LoadTable("Localization") as TextAsset; } #else TextAsset txt = BundleManager.LoadTable("Localization") as TextAsset; if (txt == null) { txt = Resources.Load("Data/Localization", typeof(TextAsset)) as TextAsset; } #endif SystemLanguage syslanguage = Application.systemLanguage; string language = PlayerPrefs.GetString("Language", "English"); if (txt != null && LoadCSV(txt)) { SelectLanguage(language); return(true); } #if UNITY_EDITOR Debug.LogWarning("Localization file not found!"); #endif return(false); }
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 bool BuildSingleBundle(BundleData bundle) { UnityEngine.Object assetObj = null; string outputPath = GenerateOutputBundlePath(bundle.name); if (!LoadAssetObjectByAssetPath(bundle.assetPath, out assetObj)) { return(false); } uint crc = 0; long changTime = DateTime.Now.ToBinary(); bool succeed = BuildAssetBundle(assetObj, outputPath, out crc); BundleBuildState bundleState = BundleManager.GetBuildStateNoNull(bundle.assetPath); if (succeed) { bundleState.crc = crc; bundleState.lastDependencies = bundle.depends.ToArray(); FileInfo info = new FileInfo(outputPath); bundleState.size = info.Length; bundleState.changeTime = changTime; } else { bundleState.lastDependencies = null; } // 每次写入,文件过多会有性能问题 //BMDataAccessor.SaveBundleBuildeStates(); return(succeed); }
public override bool Update() { if (m_Request != null) { return(false); } LoadedBundle bundle = BundleManager.GetLoadedBundle(m_AssetBundleName, out m_DownloadingError); if (bundle != null) { if (m_IsAdditive) { m_Request = Application.LoadLevelAdditiveAsync(m_LevelName); } else { m_Request = Application.LoadLevelAsync(m_LevelName); } return(false); } else { return(true); } }
IEnumerator AdvancedApiSamples() { //load asset and assign release when gameobject is destroyed { //use using clause for easier release Texture2D memberTexture; using (var loadReq = BundleManager.LoadAsync <Texture2D>("Texture", "TextureName")) { yield return(loadReq); memberTexture = loadReq.Asset; BundleManager.TrackObjectWithOwner(gameObject, memberTexture); } //here the texture will not be unloaded until gameobject destruction. //so you don't have to care about it's release //if we need to swap the texture using (var loadReq = BundleManager.LoadAsync <Texture2D>("Texture", "TextureName2")) { yield return(loadReq); //cancel owner and untrack BundleManager.UntrackObjectWithOwner(gameObject, memberTexture); memberTexture = loadReq.Asset; //re-track with owner with new asset BundleManager.TrackObjectWithOwner(gameObject, memberTexture); } } }
async Task AsyncAwaitSamples() { //initialize with task aupport { //show log message BundleManager.LogMessages = true; //show some ongui elements for debugging BundleManager.ShowDebugGUI = true; //initialize bundle system & load local bundles await BundleManager.Initialize(); //get download size from latest bundle manifest var manifestReq = await BundleManager.GetManifest(); if (!manifestReq.Succeeded) { //handle error Debug.LogError(manifestReq.ErrorCode); } //load asset with async/await using (var loadReq = await BundleManager.LoadAsync <GameObject>("Prefab", "PrefabName")) { var instance = BundleManager.Instantiate(loadReq.Asset); } } }
void Init() { //初始化顺序不能变 downloadMgr = gameObject.AddComponent<DownloadManager>(); bundleMgr = gameObject.AddComponent<BundleManager>(); luaMgr = new LuaScriptMgr(); LuaStatic.Load = Utils.LuaLoader; downloadMgr.Init(); bundleMgr.Init(); Utils.DoFile("Init"); }
/// <summary> /// Constructor /// </summary> /// <param name="env"></param> /// <param name="config"></param> public SmidgeController( IApplicationEnvironment env, ISmidgeConfig config, FileSystemHelper fileSystemHelper, IHasher hasher, BundleManager bundleManager, IUrlManager urlManager) { _urlManager = urlManager; _hasher = hasher; _env = env; _config = config; _fileSystemHelper = fileSystemHelper; _bundleManager = bundleManager; }
void Awake() { if (object.ReferenceEquals (instance, null)) { instance = this; } else if (!object.ReferenceEquals (instance, this)) { Destroy (gameObject); return; } DontDestroyOnLoad (gameObject); string platform = ""; #if UNITY_IOS platform = "iOS"; #elif UNITY_ANDROID platform = "Android"; #elif UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN platform = "PC"; #elif UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX platform = "OSX"; #elif UNITY_WEBPLAYER platform = "Web"; #elif UNITY_WP8 platform = "WP8"; #else platform = "error"; Debug.Log("unsupported platform"); #endif pathToBundles += platform + "/"; bundles = new Dictionary<string, AssetBundle> (); bundleVariants = new Dictionary<string, string> (); StartCoroutine (LoadManifest(platform)); }
public SmidgeScriptTagHelper(SmidgeHelper smidgeHelper, BundleManager bundleManager, IHtmlEncoder encoder) { _smidgeHelper = smidgeHelper; _bundleManager = bundleManager; _encoder = encoder; }
static public BundleManager getInstance() { if (instance != null) return instance; checkOldVersion(); instance = new BundleManager(); instance.Init(); return instance; }
void Awake (){ It = this; bundleManager = gameObject.AddComponent<BundleManager>(); }