/// <summary> /// 返还素材 /// </summary> /// <param name="originPath">文件的路径,以Asset/Export为根目录</param> /// <param name="uObject">文件对象</param> /// <returns></returns> protected bool actualRecycle(UObject uObject) { #if DEBUG if (uObject is Component) { DebugUtil.LogError("Res can't recyle Compomet or Transform "); } #endif if (!_init) { throw new Exception("Res has not initialised,It can be used after initialised in GameController !"); } if (uObject == null) { DebugUtil.LogError("Res Recycle a null Object !!"); return(false); } if (assetBook.ContainsKey(uObject)) { CachedObject co = assetBook[uObject]; bool recyleSucess = false; if (co != null) { recyleSucess = co.Recycle(uObject); if (co.rt != CachedObject.ResourceType.Single || co.RefCount == 0) { assetBook.Remove(uObject); } } return(recyleSucess); } else { #if UNITY_EDITOR if (uObject is GameObject) { ResNotifyDestroy rnd = (uObject as GameObject).GetComponent <ResNotifyDestroy>(); if (rnd == null) { DebugUtil.LogError(uObject.name + ", The Object is not in assetBook when Res Recyle"); } else { DebugUtil.LogError(string.Format("{0}, The Object is not in assetBook when Res Recyle,useCount:{1},recyleCount{2}", uObject.name, rnd.UseCount, rnd.RecyltCount)); } return(false); } #endif DebugUtil.LogError(uObject.name + ", The Object is not in assetBook when Res Recyle"); //Destroy(uObject); } return(false); }
private void RemoveDestroyNotify(GameObject go) { #if UNITY_EDITOR if (go == null) { return; } ResNotifyDestroy rnf = go.GetComponent <ResNotifyDestroy>(); if (go != null && rnf != null) { rnf.activeNotify = false; GameObject.Destroy(rnf); } #endif }