Files
o3de/AutomatedTesting/Gem/PythonTests/automatedtesting_shared/landscape_canvas_utils.py
T
jckand-amzn aab3d8df67 Converting Landscape Canvas tests to utilize the prefab system (#7142)
* Converting LandscapeCanvas automated tests to utilize prefab system

Signed-off-by: jckand-amzn <82226555+jckand-amzn@users.noreply.github.com>

* Finalizing LandscapeCanvas automated test conversions to utilize prefab system

Signed-off-by: jckand-amzn <82226555+jckand-amzn@users.noreply.github.com>

* Removing test gem from enabled_gems for AutomatedTesting

Signed-off-by: jckand-amzn <82226555+jckand-amzn@users.noreply.github.com>

* Removing test gem subdirectory that was mistakenly committed

Signed-off-by: jckand-amzn <82226555+jckand-amzn@users.noreply.github.com>

* Removing debug wait

Signed-off-by: jckand-amzn <82226555+jckand-amzn@users.noreply.github.com>
2022-01-25 13:45:30 -06:00

35 lines
1.4 KiB
Python
Executable File

"""
Copyright (c) Contributors to the Open 3D Engine Project.
For complete copyright and license terms please see the LICENSE at the root of this distribution.
SPDX-License-Identifier: Apache-2.0 OR MIT
"""
import azlmbr.bus as bus
import azlmbr.editor as editor
import azlmbr.landscapecanvas as landscapecanvas
import editor_python_test_tools.hydra_editor_utils as hydra
def find_nodes_matching_entity_component(component_name, entity_id):
"""
Finds all matching nodes given a component name and entity to search on.
:param component_name: String of component name to search for
:param entity_id: The entity ID to search for the given component node on
:return List of matching nodes
"""
component_type_id = hydra.get_component_type_id(component_name)
component = editor.EditorComponentAPIBus(bus.Broadcast, 'GetComponentOfType', entity_id,
component_type_id)
if component.IsSuccess():
component_id = component.GetValue()
component_node = landscapecanvas.LandscapeCanvasRequestBus(bus.Broadcast, 'GetAllNodesMatchingEntityComponent',
component_id)
if component_node:
print(f"{component_name} node found on entity {entity_id.ToString()}")
else:
print(f"Failed to find {component_name} node on entity {entity_id.ToString()}")
return component_node