public bool RemoveAssetBundle(string assetBundleName, string assetBundleVariant) { Asset[] assetsToRemove = m_AssetBundleCollection.GetAssets(assetBundleName, assetBundleVariant); if (m_AssetBundleCollection.RemoveAssetBundle(assetBundleName, assetBundleVariant)) { List <SourceAsset> unassignedSourceAssets = new List <SourceAsset>(); foreach (Asset asset in assetsToRemove) { SourceAsset sourceAsset = GetSourceAsset(asset.Guid); if (sourceAsset != null) { unassignedSourceAssets.Add(sourceAsset); } } if (OnAssetUnassigned != null) { OnAssetUnassigned(unassignedSourceAssets.ToArray()); } return(true); } return(false); }
public void Analyze() { m_DependencyDatas.Clear(); m_ScatteredAssets.Clear(); m_AnalyzedStamps.Clear(); HashSet <string> scriptAssetNames = GetFilteredAssetNames("t:Script"); Asset[] assets = m_AssetBundleCollection.GetAssets(); int count = assets.Length; for (int i = 0; i < count; i++) { OnAnalyzingAsset?.Invoke(i, count); string assetName = assets[i].Name; if (string.IsNullOrEmpty(assetName)) { Debug.LogWarning(string.Format("Can not find asset by guid '{0}'.", assets[i].Guid)); continue; } DependencyData dependencyData = new DependencyData(); AnalyzeAsset(assetName, assets[i], dependencyData, scriptAssetNames); dependencyData.RefreshData(); m_DependencyDatas.Add(assetName, dependencyData); } foreach (List <Asset> scatteredAsset in m_ScatteredAssets.Values) { scatteredAsset.Sort((a, b) => a.Name.CompareTo(b.Name)); } OnAnalyzeCompleted?.Invoke(); }