private void EndLoad(LoadItem item, IAsset asset) { if (item == null) { return; } // 移除加载字典 if (_loadDict.ContainsKey(item.url)) { _loadDict.Remove(item.url); } // 填充LoadItem item.asset = asset; // 执行加载完成回调 if (item.completeCallback != null) { item.completeCallback.Invoke(item); } else if (item.cache == false) { asset.Dispose(); } }
public void UnloadAsset(IAsset asset) { Type assetType = asset.GetType(); if (m_assets.ContainsKey(assetType)) { m_assets[assetType].Remove(asset); } asset.Dispose(); }
public void Unload(IAsset asset) { if (!_assetCache.Remove(asset.SourcePath)) { throw new ArgumentException("Asset was not found in AssetManager. This will occur if the asset's " + "SourcePath value is changed manually."); } if (asset is IReloadableAsset reloadableAsset) { AssetReloader.RemoveReloadable(reloadableAsset); } OnAssetUnloading(asset); _loadedAssets.Remove(asset); asset.Dispose(); }
/// <summary> /// 清理游戏对象 /// </summary> public void ClearGameObjects() { float time = Time.time; List <IAsset> removedList = new List <IAsset>(10); foreach (var v in _assetDict) { IAsset asset = v.Value; if (asset.autoClear == false) { continue; } if (asset.lastUseTime > 0 && asset.useCount == 0) { if (_checkAutoClearDelegate != null) { if (_checkAutoClearDelegate.Invoke(asset)) { continue; } } if (time - asset.lastUseTime >= _autoClearTime) { removedList.Add(asset); } } } foreach (IAsset asset in removedList) { asset.Dispose(); _assetDict.Remove(asset.id); } }