Add Light component GPU (screenshot) test to AutomatedTesting nightly o3de runs. (#2923)

* adds the Light component GPU screenshot test to AutomatedTesting

Signed-off-by: jromnoa <jromnoa@amazon.com>

* add LIGHT_TYPE_PROPERTY constant to test script since it is re-used multiple times

Signed-off-by: jromnoa <jromnoa@amazon.com>

* removes redundant f strings, adds LIGHT_COMPONENT and LIGHT_TYPE_PROPERTY constants for re-use, removed formattng errors, increase CMakeLists.txt timeout, add attach_component_to_entity() to hydra_editor_utils.py

Signed-off-by: jromnoa <jromnoa@amazon.com>

* fix ImportError

Signed-off-by: jromnoa <jromnoa@amazon.com>

* moves the LIGHT_TYPES constant to a new file since scripts rely on it that do not have the Editor launched (can't see hydra bindings so failes with ModuleNotFound error)

Signed-off-by: jromnoa <jromnoa@amazon.com>
This commit is contained in:
jromnoa
2021-08-11 11:19:22 -07:00
committed by GitHub
parent fbcb6510e6
commit 6d1bb8e439
20 changed files with 607 additions and 18 deletions
@@ -8,6 +8,7 @@ SPDX-License-Identifier: Apache-2.0 OR MIT
import azlmbr.bus as bus
import azlmbr.editor as editor
import azlmbr.entity as entity
import azlmbr.legacy.general as general
import azlmbr.object
from typing import List
@@ -428,3 +429,32 @@ def get_component_type_id_map(component_name_list):
type_ids_by_component[component_names[i]] = typeId
return type_ids_by_component
def attach_component_to_entity(entity_id, component_name):
# type: (azlmbr.entity.EntityId, str) -> azlmbr.entity.EntityComponentIdPair
"""
Adds the component if not added already.
:param entity_id: EntityId of the entity to attach the component to
:param component_name: name of the component
:return: If successful, returns the EntityComponentIdPair, otherwise returns None.
"""
type_ids_list = editor.EditorComponentAPIBus(
bus.Broadcast, 'FindComponentTypeIdsByEntityType', [component_name], 0)
general.log(f"Components found = {len(type_ids_list)}")
if len(type_ids_list) < 1:
general.log(f"ERROR: A component class with name {component_name} doesn't exist")
return None
elif len(type_ids_list) > 1:
general.log(f"ERROR: Found more than one component classes with same name: {component_name}")
return None
# Before adding the component let's check if it is already attached to the entity.
component_outcome = editor.EditorComponentAPIBus(bus.Broadcast, 'GetComponentOfType', entity_id, type_ids_list[0])
if component_outcome.IsSuccess():
return component_outcome.GetValue() # In this case the value is not a list.
component_outcome = editor.EditorComponentAPIBus(bus.Broadcast, 'AddComponentsOfType', entity_id, type_ids_list)
if component_outcome.IsSuccess():
general.log(f"{component_name} Component added to entity.")
return component_outcome.GetValue()[0]
general.log(f"ERROR: Failed to add component [{component_name}] to entity")
return None