void OnEnable() { visitor = new EntityIMGUIVisitor(entity => { var targetProxy = (EntitySelectionProxy)target; if (!targetProxy.Exists) { return; } EntitySelectionProxy.SelectEntity(targetProxy.World, entity); }, entity => currentEntityManager.GetName(entity)); inclusionList = new SystemInclusionList(); }
void OnLocalSelectionChanged(EntityHierarchyItem selectedItem) { m_SelectedItem = selectedItem.NodeId; if (selectedItem.NodeId.Kind == NodeKind.Entity) { var entity = selectedItem.NodeId.ToEntity(); if (entity != Entity.Null) { var undoGroup = Undo.GetCurrentGroup(); EntitySelectionProxy.SelectEntity(m_Hierarchy.World, entity); // Collapsing the selection of the entity into the selection of the ListView / TreeView item Undo.CollapseUndoOperations(undoGroup); } } else { // TODO: Deal with non-Entity selections } }
static void OnClicked(ClickEvent evt, EntityInspectorContext context, VisualElement current) { switch (current) { case Foldout foldout: if (!foldout.Q <Toggle>().worldBound.Contains(evt.position)) { break; } foldout.value = !foldout.value; break; case ObjectField objectField: var display = objectField.Q(className: UssClasses.UIToolkit.ObjectField.Display); if (null == display) { break; } if (!display.worldBound.Contains(evt.position)) { break; } if (evt.clickCount == 1) { EditorGUIUtility.PingObject(objectField.value); } else { var value = objectField.value; if (null != value && value) { Selection.activeObject = value; } } break; case EntityField entityField: var input = entityField.Q(className: "unity-entity-field__input"); if (null == input) { break; } if (!input.worldBound.Contains(evt.position)) { break; } if (evt.clickCount > 1) { var world = context.World; if (null == world || !world.IsCreated) { break; } if (!context.EntityManager.Exists(entityField.value)) { break; } EntitySelectionProxy.SelectEntity(context.World, entityField.value); } break; } for (var i = 0; i < current.childCount; ++i) { OnClicked(evt, context, current[i]); } }