private static void LogRefCount(BundleReference br, int addRefCount = 1) { if (ResourceUtil.isLog) { Debug.Log("assetBundle recCount " + br.bundleName + " " + br.refCount + " " + addRefCount); } }
IEnumerator loadCo(string effectName) { yield return(null); var url = PathUrl.GetUIEffectUrl(effectName); _effectBundle = BundleReference.Get(url, this); if (!_effectBundle.contains(effectName)) { _fxSort.enabled = false; yield break; } var prefab = _effectBundle.load <GameObject>(effectName); if (prefab == null) { yield break; } _effectGO = Instantiate(prefab) as GameObject; var t = _effectGO.transform; t.localPosition = Vector3.zero; t.localRotation = Quaternion.identity; t.localScale = Vector3.one; _fxSort.enabled = true; _fxSort.ResortRenderers(); }
public void notifyRelease(BundleReference r, Bundle b) { b.references.Remove(r); if (b.references.Count <= 0) { dict.Remove(b.assetBundleName); b.destroy(); } }
public static bool IsAssetBundleCraete(string bundleName) { BundleReference br = GetBundleReference(bundleName); if (br != null) { return(br.assetBundle != null); } return(false); }
private static BundleReference GetBundleReference(string bundleName) { BundleReference br = null; if (_bundleReferenceList.TryGetValue(bundleName, out br)) { return(br); } return(null); }
public static AssetBundle GetAssetBundleDirect(string bundleName) { BundleReference br = GetBundleReference(bundleName);; if (br != null) { return(br.assetBundle); } return(null); }
private static BundleReference GetTempBundleReference() { BundleReference br = null; if (_freeBundleReferenceList.Count > 0) { br = _freeBundleReferenceList[0]; } else { br = new BundleReference(); } return(br); }
public static void ReleaseBundle(string bundleName) { BundleReference br = null; if (_bundleReferenceList.TryGetValue(bundleName, out br)) { // 释放依赖 List <string> dependencies = BundleDependencies.GetAssetBundleDependencies(bundleName); if (dependencies != null) { foreach (string dependBundleName in dependencies) { ReleaseBundle(dependBundleName); } } br.refCount--; LogRefCount(br, -1); } }
private static void RecoveryObjectReference(string bundleName) { BundleReference br = null; if (!_bundleReferenceList.TryGetValue(bundleName, out br)) { return; } // bundle引用为0 if (br.assetBundle) { Debug.Log("assetBundle Unload(true) " + bundleName); br.assetBundle.Unload(true); } _bundleReferenceList.Remove(bundleName); br.Clear(); _freeBundleReferenceList.Add(br); }
public static void AddBundle(string bundleName, AssetBundle assetBundle) { if (assetBundle == null) { return; } if (_bundleReferenceList.ContainsKey(bundleName)) { GetAssetBundle(bundleName); } else { BundleReference br = GetTempBundleReference(); br.bundleName = bundleName; br.assetBundle = assetBundle; _bundleReferenceList.Add(bundleName, br); GetAssetBundle(bundleName); } }
public static void Update() { if (_bundleReferenceList.Count == 0) { return; } List <string> tempBrs = new List <string>(); foreach (string bundleName in _bundleReferenceList.Keys) { BundleReference br = _bundleReferenceList[bundleName]; if (br.refCount <= 0) { tempBrs.Add(bundleName); } } foreach (string bundleName in tempBrs) { RecoveryObjectReference(bundleName); } }
/// <summary> /// 获取一个bundle 每次获取引用计数都会加1 /// </summary> /// <param name="bundleName"></param> /// <returns></returns> public static AssetBundle GetAssetBundle(string bundleName) { BundleReference br = GetBundleReference(bundleName);; if (br != null) { br.refCount++; LogRefCount(br, 1); // 增加依赖 List <string> denpendencies = BundleDependencies.GetAssetBundleDependencies(bundleName); if (denpendencies != null) { foreach (string denpendBundleName in denpendencies) { GetAssetBundle(denpendBundleName); } } return(br.assetBundle); } return(null); }
/// <summary>Handles the Load event of the Page control.</summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> protected void Page_Load(object sender, EventArgs e) { // Check if forum is installed try { var boards = BoardContext.Current.GetRepository <Board>().GetAll(); var isForumInstalled = boards.Any(); } catch { // failure... no boards. HttpContext.Current.Response.Redirect($"{BoardInfo.ForumClientFileRoot}install/default.aspx"); } var scriptManager = ScriptManager.GetCurrent(this.Page); var forum = this.MainContent.FindControl("forum"); if (forum != null) { var link = new HtmlLink { Href = "~/Content/Site.css" }; link.Attributes.Add("rel", "stylesheet"); link.Attributes.Add("type", "text/css"); this.Page.Header.Controls.Add(link); } else { scriptManager.Scripts.Insert( 0, new ScriptReference(BoardInfo.GetURLToScripts($"jquery-{Config.JQueryVersion}.min.js"))); scriptManager.Scripts.Add( new ScriptReference(BoardInfo.GetURLToScripts("jquery.ForumExtensions.min.js"))); var link = new HtmlLink(); link.Attributes.Add("rel", "stylesheet"); link.Attributes.Add("type", "text/css"); link.Href = BoardContext.Current != null ? BoardContext.Current.Get <ITheme>().BuildThemePath("bootstrap-forum.min.css") : "~/Forum/Content/Themes/yaf/bootstrap-forum.min.css"; this.Page.Header.Controls.Add(link); var linkForum = new HtmlLink { Href = "~/Forum/Content/forum.min.css" }; linkForum.Attributes.Add("rel", "stylesheet"); linkForum.Attributes.Add("type", "text/css"); this.Page.Header.Controls.Add(linkForum); var bundleReference = new BundleReference { Path = "~/Content/css" }; this.Page.Header.Controls.Add(bundleReference); } }