From 282861da3e76f33f836fbfb086849327f237c0b1 Mon Sep 17 00:00:00 2001 From: David Gordon <94419856+dinomut1@users.noreply.github.com> Date: Mon, 17 Jun 2024 13:00:26 -0700 Subject: [PATCH] add dependency to hierarchy generation that updates with every sourced entity created (#10401) --- .../components/editor/panels/Hierarchy/container/index.tsx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/ui/src/components/editor/panels/Hierarchy/container/index.tsx b/packages/ui/src/components/editor/panels/Hierarchy/container/index.tsx index df2429ce67..cbfc0e90c7 100644 --- a/packages/ui/src/components/editor/panels/Hierarchy/container/index.tsx +++ b/packages/ui/src/components/editor/panels/Hierarchy/container/index.tsx @@ -40,7 +40,7 @@ import AutoSizer from 'react-virtualized-auto-sizer' import { FixedSizeList } from 'react-window' import { NotificationService } from '@etherealengine/client-core/src/common/services/NotificationService' -import { Engine, EntityUUID, UUIDComponent, entityExists } from '@etherealengine/ecs' +import { Engine, EntityUUID, UUIDComponent, entityExists, useQuery } from '@etherealengine/ecs' import { CameraOrbitComponent } from '@etherealengine/spatial/src/camera/components/CameraOrbitComponent' import useUpload from '@etherealengine/editor/src/components/assets/useUpload' @@ -56,6 +56,7 @@ import { cmdOrCtrlString } from '@etherealengine/editor/src/functions/utils' import { EditorState } from '@etherealengine/editor/src/services/EditorServices' import { SelectionState } from '@etherealengine/editor/src/services/SelectionServices' import { GLTFAssetState, GLTFSnapshotState } from '@etherealengine/engine/src/gltf/GLTFState' +import { SourceComponent } from '@etherealengine/engine/src/scene/components/SourceComponent' import { PopoverPosition } from '@mui/material' import { HiMagnifyingGlass, HiOutlinePlusCircle } from 'react-icons/hi2' import { HierarchyPanelTab } from '..' @@ -90,7 +91,7 @@ function HierarchyPanelContents(props: { sceneURL: string; rootEntityUUID: Entit const [selectedNode, _setSelectedNode] = useState(null) const lockPropertiesPanel = useHookstate(getMutableState(EditorState).lockPropertiesPanel) const searchHierarchy = useHookstate('') - + const sourcedEntities = useQuery([SourceComponent]) const rootEntity = UUIDComponent.useEntityByUUID(rootEntityUUID) const rootEntityTree = useComponent(rootEntity, EntityTreeComponent) @@ -122,7 +123,7 @@ function HierarchyPanelContents(props: { sceneURL: string; rootEntityUUID: Entit useEffect(() => { entityHierarchy.set(Array.from(heirarchyTreeWalker(sceneURL, rootEntity))) - }, [expandedNodes, index, rootEntityTree.children]) + }, [expandedNodes, index, rootEntityTree.children, sourcedEntities.length]) const setSelectedNode = (selection) => !lockPropertiesPanel.value && _setSelectedNode(selection)