void CellGUI(Rect cellRect, TreeViewItem <AssetTreeElement> item, AssetColumns column, ref RowGUIArgs args) { // Center cell rect vertically (makes it easier to place controls, icons etc in the cells) CenterRectUsingSingleLineHeight(ref cellRect); if (item.data.depth == 0) { HeaderCellGUI(cellRect, item, column, ref args); return; } AssetItem ai = item.data.ai; AssetTreeElement element = item.data; switch (column) { case AssetColumns.Selection: { // EditorGUI.Toggle(cellRect, item.data.ai._SerializedItem != null); bool newVal = EditorGUI.Toggle(cellRect, element.Checked); if (newVal != element.Checked) { element.Checked = newVal; RecalcTypeChecks(element.type); } } break; case AssetColumns.Type: { EditorGUI.LabelField(cellRect, element.type.Name); } break; case AssetColumns.Always: { cellRect.x += kCheckboxOffset; cellRect.width -= kCheckboxOffset; bool clicked = EditorGUI.Toggle(cellRect, ai.IsAlwaysLoaded); if (clicked != ai.IsAlwaysLoaded) { ai.IsAlwaysLoaded = clicked; UMAAssetIndexer.Instance.ForceSave(); } } break; case AssetColumns.IsResource: { cellRect.x += kCheckboxOffset; cellRect.width -= kCheckboxOffset; EditorGUI.Toggle(cellRect, ai.IsResource); } break; case AssetColumns.Name: { // Do toggle Rect toggleRect = cellRect; toggleRect.x += GetContentIndent(item); toggleRect.width = kToggleWidth; //if (toggleRect.xMax < cellRect.xMax) // item.data.enabled = EditorGUI.Toggle(toggleRect, item.data.enabled); // hide when outside cell rect // Default icon and label args.rowRect = cellRect; base.RowGUI(args); } break; case AssetColumns.IsAddressable: { cellRect.x += kCheckboxOffset; cellRect.width -= kCheckboxOffset; EditorGUI.Toggle(cellRect, ai.IsAddressable); } break; case AssetColumns.Group: EditorGUI.LabelField(cellRect, ai.AddressableGroup); break; case AssetColumns.Labels: { if (!string.IsNullOrEmpty(ai.AddressableLabels)) { Rect Button = new Rect(cellRect); Button.width = 32; Button.height -= 2; if (GUI.Button(Button, "View", EditorStyles.toolbarButton)) { List <string> labels = new List <string>(); labels.AddRange(ai.AddressableLabels.Split(';')); DisplayListWindow.ShowDialog("Addressable Labels", owningWindow.position, labels); } cellRect.x += 32; cellRect.width -= 32; EditorGUI.LabelField(cellRect, ai.AddressableLabels); } } break; case AssetColumns.Buttons: { float BtnWidth = (cellRect.width / 3) - (kToggleWidth * 2); Rect ButtonRect = new Rect(cellRect); ButtonRect.width = BtnWidth; if (GUI.Button(ButtonRect, "Inspect", EditorStyles.toolbarButton)) { UnityEngine.Object o = AssetDatabase.LoadMainAssetAtPath(ai._Path); InspectorUtlity.InspectTarget(o); } /* * ButtonRect.x = ButtonRect.x + BtnWidth; * if (item.data.ai._SerializedItem == null) * { * if(GUI.Button(ButtonRect, "Add Ref", EditorStyles.toolbarButton)) * { * ai.CacheSerializedItem(); * Repaint(); * } * } * else * { * if(GUI.Button(ButtonRect, "Rmv Ref",EditorStyles.toolbarButton)) * { * ai.ReleaseItem(); * Repaint(); * } * } */ #if UMA_ADDRESSABLES if (ai.Item is UMATextRecipe) { UMATextRecipe recipe = ai.Item as UMATextRecipe; if (owningWindow.LoadedLabels.Contains(recipe.AssignedLabel)) { ButtonRect.x = ButtonRect.x + ButtonRect.width; ButtonRect.width = 110; if (GUI.Button(ButtonRect, "Update Groups", EditorStyles.toolbarButton)) { UMAAssetIndexer.Instance.AddRecipeGroup(recipe); owningWindow.LoadedLabels.Add(recipe.AssignedLabel); } } else { ButtonRect.x = ButtonRect.x + ButtonRect.width; ButtonRect.width = 110; if (GUI.Button(ButtonRect, "Make Addressable", EditorStyles.toolbarButton)) { UMAAssetIndexer.Instance.AddRecipeGroup(recipe); owningWindow.LoadedLabels.Add(recipe.AssignedLabel); } } } #endif ButtonRect.x = ButtonRect.x + ButtonRect.width; ButtonRect.width = 32; if (GUI.Button(ButtonRect, "Ping", EditorStyles.toolbarButton)) { UnityEngine.Object o = AssetDatabase.LoadMainAssetAtPath(ai._Path); EditorGUIUtility.PingObject(o); } ButtonRect.x = ButtonRect.x + 32; ButtonRect.width = kToggleWidth; if (GUI.Button(ButtonRect, "X", EditorStyles.toolbarButton)) { // remove from index. // remove from tree. List <AssetTreeElement> RemoveMe = new List <AssetTreeElement>(); UMAAssetIndexer.Instance.RemoveAsset(ai._Type, ai._Name); RemoveMe.Add(item.data); this.treeModel.RemoveElements(RemoveMe); owningWindow.RecountTypes(); RecalcTypeChecks(element.type); Repaint(); } } break; } }
void HeaderCellGUI(Rect cellRect, TreeViewItem <AssetTreeElement> item, AssetColumns column, ref RowGUIArgs args) { AssetTreeElement ate = item.data; switch (column) { case AssetColumns.Selection: { // EditorGUI.Toggle(cellRect, item.data.ai._SerializedItem != null); if (item.data.AmountChecked == Amount.Mixed) { EditorGUI.showMixedValue = true; } bool checkval = item.data.AmountChecked == Amount.All; bool newval = EditorGUI.Toggle(cellRect, checkval); EditorGUI.showMixedValue = false; if (checkval != newval) { SetAllChildren(item.data.type, newval); } // checking/unchecking this will toggle ALL the items below. } break; case AssetColumns.Always: { GUI.Label(cellRect, ate.Keepcount.ToString()); } break; case AssetColumns.IsResource: { GUI.Label(cellRect, ate.IsResourceCount.ToString()); } break; case AssetColumns.Name: { Rect toggleRect = cellRect; toggleRect.x += GetContentIndent(item); // Default icon and label args.rowRect = cellRect; base.RowGUI(args); // DefaultGUI.Label(cellRect, item.data.name, false, false); } break; case AssetColumns.IsAddressable: { GUI.Label(cellRect, ate.IsAddrCount.ToString()); } break; case AssetColumns.Group: break; case AssetColumns.Labels: break; case AssetColumns.Buttons: { string QualifiedName = item.data.type.AssemblyQualifiedName; if (UMAAssetIndexer.Instance.IsAdditionalIndexedType(QualifiedName)) { if (GUI.Button(cellRect, "Remove this Type", EditorStyles.toolbarButton)) { UMAAssetIndexer.Instance.RemoveType(item.data.type); List <AssetTreeElement> RemoveMe = new List <AssetTreeElement>(); RemoveMe.Add(item.data); this.treeModel.RemoveElements(RemoveMe); } } //string QualifiedName = sType.AssemblyQualifiedName; //if (!IsAdditionalIndexedType(QualifiedName)) return; } break; } }