void DrawDetails(AssetBundles.AssetBundleInfo abInfo) { if (abInfo == null) { return; } bool isLoaded = IsAssetBundleLoaded(abInfo.Name); string loadError = null; AssetBundles.AssetBundleRef abRef; if (AssetBundles.abRefs.TryGetValue(abInfo.Key, out abRef)) { if (abRef.AssetBundle) { } else { if (abRef.Error != null) { loadError = abRef.Error.Message; } } } GUILayout.Label(abInfo.Name); GUILayout.Space(5); if (loadError != null) { GUI.color = Color.red; GUILayout.Label(loadError); GUI.color = Color.white; } var deps = manifest.GetDirectDependencies(abInfo.Name); if (GUILayout.Button(string.Format("Dependency ({0})", deps.Length), "label")) { isDependencyExpanded = !isDependencyExpanded; } if (isDependencyExpanded) { foreach (var dep in deps) { using (new GUILayout.HorizontalScope()) { GUILayout.Space(16); GUILayout.Label(dep); } } } GUILayout.Space(5); var depSelf = (from abName in AssetBundles.AllAssetBundleNames() where manifest.GetDirectDependencies(abName).Contains(abInfo.Name) select abName).ToArray(); if (GUILayout.Button(string.Format("Dependency Self ({0})", depSelf.Length), "label")) { isDependencySelfExpanded = !isDependencySelfExpanded; } if (isDependencySelfExpanded) { foreach (var abName in depSelf) { using (new GUILayout.HorizontalScope()) { GUILayout.Space(16); GUILayout.Label(abName); } } } GUILayout.Space(5); List <AssetBundles.AssetBundleRef> ownerDeps = new List <AssetBundles.AssetBundleRef>(); if (abRef != null) { foreach (var item in AssetBundles.abRefs.Values) { if (item == abRef) { continue; } if (!item.IsDependent) { continue; } if (item.AssetBundleInfo.Dependencies != null) { foreach (var dep in item.AssetBundleInfo.Dependencies) { if (dep == abRef.AssetBundleInfo) { ownerDeps.Add(item); } } } } } using (new GUILayout.HorizontalScope()) { if (GUILayout.Button(string.Format("Lifetime Dependency ({0})", ownerDeps.Count), "label")) { isOwnerDependencyExpanded = !isOwnerDependencyExpanded; } } if (isOwnerDependencyExpanded) { foreach (var item in ownerDeps) { using (new GUILayout.HorizontalScope()) { GUILayout.Space(16); GUILayout.Label(item.AssetBundleInfo.Name); } } } List <object> lifetimeObjects = new List <object>(); if (isLoaded && abRef != null) { foreach (WeakReference weakRef in abRef.Owners) { object obj = weakRef.Target; if (obj != null) { lifetimeObjects.Add(obj); } } } using (new GUILayout.HorizontalScope()) { if (GUILayout.Button(string.Format("Lifetime ({0})", lifetimeObjects.Count), "label")) { isOwnerObjectExpanded = !isOwnerObjectExpanded; } } if (isOwnerObjectExpanded) { if (isLoaded && abRef != null) { foreach (var obj in lifetimeObjects) { if (obj != null) { using (new GUILayout.HorizontalScope()) { GUILayout.Space(16); if (GUILayout.Button(string.Format("{0} ({1})", (obj.ToString() ?? string.Empty), obj.GetType().FullName), "label")) { if (obj is UnityEngine.Object) { Object o = obj as UnityEngine.Object; EditorGUIUtility.PingObject(o); } } } } } } } }
void DrawAssetBundle(AssetBundles.AssetBundleInfo abInfo) { bool isLoaded = IsAssetBundleLoaded(abInfo.Name); string loadError = null; AssetBundles.AssetBundleRef abRef; if (AssetBundles.abRefs.TryGetValue(abInfo.Key, out abRef)) { if (abRef.AssetBundle) { } else { if (abRef.Error != null) { loadError = abRef.Error.Message; } } } int controllId; controllId = GUIUtility.GetControlID(FocusType.Passive); AssetBundleItemState state = (AssetBundleItemState)GUIUtility.GetStateObject(typeof(AssetBundleItemState), controllId); if (selectedAssetBundleInfo == abInfo) { GUI.backgroundColor = new Color(0.5f, 0.5f, 0.5f, 0.1f); } else { GUI.backgroundColor = Color.clear; } using (new GUILayout.HorizontalScope(BgStyle)) { if (isLoaded) { GUI.color = Color.white; } else if (loadError != null) { GUI.color = Color.red; } else { GUI.color = Color.gray; } if (GUILayout.Button(abInfo.Name, "label")) { state.isExpanded = !state.isExpanded; selectedAssetBundleInfo = abInfo; } GUI.color = Color.white; if (state.isExpanded) { } } GUI.backgroundColor = Color.white; }