/// <inheritdoc cref="IDrawer.Dispose" /> public override void Dispose() { #if UNITY_EDITOR GUIContentArrayPool.Dispose(ref assetLabels); Sisus.AssetLabels.OnAssetLabelsChanged -= OnAssetLabelsChanged; #endif base.Dispose(); }
/// <inheritdoc cref="IDrawer.Dispose" /> public override void Dispose() { if (!ReferenceEquals(assetEditor, null)) { Editors.Dispose(ref assetEditor); } editorTargets = null; // Make sure that asset Editor is updated properly if (ReferenceEquals(editor, assetEditor)) { assetEditor = null; } GUIContentArrayPool.Dispose(ref assetLabels); Sisus.AssetLabels.OnAssetLabelsChanged -= OnAssetLabelsChanged; base.Dispose(); }
public static void Get(Object[] targets, ref GUIContent[] assetLabels, ref GUIContent[] assetLabelsOnlyOnSomeTargets) { var first = targets[0]; if (first == null || !AssetDatabase.Contains(first)) { ArrayPool <GUIContent> .Resize(ref assetLabels, 0); ArrayPool <GUIContent> .Resize(ref assetLabelsOnlyOnSomeTargets, 0); return; } var firstAssetLabels = AssetDatabase.GetLabels(first); int firstAssetLabelsCount = firstAssetLabels.Length; if (firstAssetLabelsCount == 0) { ArrayPool <GUIContent> .Resize(ref assetLabels, 0); ArrayPool <GUIContent> .Resize(ref assetLabelsOnlyOnSomeTargets, 0); return; } int targetCount = targets.Length; if (targetCount == 1) { if (assetLabels != null) { GUIContentArrayPool.Dispose(ref assetLabels); } assetLabels = GUIContentArrayPool.Create(firstAssetLabels); GUIContentArrayPool.Resize(ref assetLabelsOnlyOnSomeTargets, 0, true, false); return; } for (int l = 0; l < firstAssetLabelsCount; l++) { var testLabel = firstAssetLabels[l]; bool foundOnAll = true; for (int t = targetCount - 1; t >= 1; t--) { if (Array.IndexOf(AssetDatabase.GetLabels(targets[t]), testLabel) == -1) { foundOnAll = false; break; } } if (foundOnAll) { TempLabelsFoundOnAll.Add(testLabel); } else { TempLabelsFoundOnSome.Add(testLabel); } } if (assetLabels != null) { GUIContentArrayPool.Dispose(ref assetLabels); } assetLabels = GUIContentArrayPool.Create(TempLabelsFoundOnAll); TempLabelsFoundOnAll.Clear(); if (assetLabelsOnlyOnSomeTargets != null) { GUIContentArrayPool.Dispose(ref assetLabelsOnlyOnSomeTargets); } assetLabelsOnlyOnSomeTargets = GUIContentArrayPool.Create(TempLabelsFoundOnSome); TempLabelsFoundOnSome.Clear(); }