public bool ReleaseResource(Object obj, bool destroyObj = false) { if (obj == null) { return(false); } ResourceItem item = null; foreach (var res in AssetDic.Values) { if (res.m_Guid == obj.GetInstanceID()) { item = res; } } if (item == null) { Debug.LogError("AssetDic里不存在该资源" + obj.name + "可能释放了多次"); return(false); } item.Release(); DestroyResourceItem(item, destroyObj); return(true); }
//不需要实例化的资源卸载 根据路径 public bool ReleaseResource(string path, bool destroyObj = false) { if (string.IsNullOrEmpty(path)) { return(false); } uint crc = Crc32.GetCrc32(path); ResourceItem item = null; if (!AssetDic.TryGetValue(crc, out item) || null == item) { Debug.LogError("AssetDic里不存在该资源" + path + "可能释放了多次"); } item.Release(); DestroyResourceItem(item, destroyObj); return(true); }