diff --git a/AutomatedTesting/Gem/PythonTests/EditorPythonTestTools/editor_python_test_tools/editor_entity_utils.py b/AutomatedTesting/Gem/PythonTests/EditorPythonTestTools/editor_python_test_tools/editor_entity_utils.py index 783f71e06c..844f8de903 100644 --- a/AutomatedTesting/Gem/PythonTests/EditorPythonTestTools/editor_python_test_tools/editor_entity_utils.py +++ b/AutomatedTesting/Gem/PythonTests/EditorPythonTestTools/editor_python_test_tools/editor_entity_utils.py @@ -122,17 +122,32 @@ class EditorEntity: # Creation functions @classmethod - def find_editor_entity(cls, entity_name: str) -> EditorEntity: + def find_editor_entity(cls, entity_name: str, must_be_unique : bool = False) -> EditorEntity: """ Given Entity name, outputs entity object :param entity_name: Name of entity to find :return: EditorEntity class object """ - entity_id = general.find_editor_entity(entity_name) - assert entity_id.IsValid(), f"Failure: Couldn't find entity with name: '{entity_name}'" - entity = cls(entity_id) + entities = cls.find_editor_entities([entity_name]) + assert len(entities) != 0, f"Failure: Couldn't find entity with name: '{entity_name}'" + if must_be_unique: + assert len(entities) == 1, f"Failure: Multiple entities with name: '{entity_name}' when expected only one" + + entity = cls(entities[0]) return entity + @classmethod + def find_editor_entities(cls, entity_names: List[str]) -> EditorEntity: + """ + Given Entities names, returns a list of EditorEntity + :param entity_name: Name of entity to find + :return: List[EditorEntity] class object + """ + searchFilter = azlmbr.entity.SearchFilter() + searchFilter.names = entity_names + ids = azlmbr.entity.SearchBus(bus.Broadcast, 'SearchEntities', searchFilter) + return [cls(id) for id in ids] + @classmethod def create_editor_entity(cls, name: str = None, parent_id=None) -> EditorEntity: """ @@ -157,8 +172,7 @@ class EditorEntity: cls, entity_position: Union[List, Tuple, math.Vector3], name: str = None, - parent_id: azlmbr.entity.EntityId = None, - ) -> EditorEntity: + parent_id: azlmbr.entity.EntityId = None) -> EditorEntity: """ Used to create entity at position using 'CreateNewEntityAtPosition' Bus. :param entity_position: World Position(X, Y, Z) of entity in viewport. @@ -227,6 +241,12 @@ class EditorEntity: """ return editor.EditorEntityInfoRequestBus(bus.Event, "GetChildren", self.id) + def get_children(self) -> List[EditorEntity]: + """ + :return: List of EditorEntity children. Type: [EditorEntity] + """ + return [EditorEntity(child_id) for child_id in self.get_children_ids()] + def add_component(self, component_name: str) -> EditorComponent: """ Used to add new component to Entity. diff --git a/AutomatedTesting/Gem/PythonTests/prefab/Prefab.py b/AutomatedTesting/Gem/PythonTests/EditorPythonTestTools/editor_python_test_tools/prefab_utils.py similarity index 85% rename from AutomatedTesting/Gem/PythonTests/prefab/Prefab.py rename to AutomatedTesting/Gem/PythonTests/EditorPythonTestTools/editor_python_test_tools/prefab_utils.py index 9b4d2d1393..2d8b124125 100644 --- a/AutomatedTesting/Gem/PythonTests/prefab/Prefab.py +++ b/AutomatedTesting/Gem/PythonTests/EditorPythonTestTools/editor_python_test_tools/prefab_utils.py @@ -12,20 +12,39 @@ from os import path from PySide2 import QtWidgets +import azlmbr.legacy.general as general from azlmbr.entity import EntityId from azlmbr.math import Vector3 from editor_python_test_tools.editor_entity_utils import EditorEntity from editor_python_test_tools.utils import Report +import azlmbr.entity as entity import azlmbr.bus as bus import azlmbr.prefab as prefab import editor_python_test_tools.pyside_utils as pyside_utils -import prefab.Prefab_Test_Utils as prefab_test_utils + + +def get_prefab_file_path(prefab_path): + if not path.isabs(prefab_path): + prefab_path = path.join(general.get_file_alias("@projectroot@"), prefab_path) + + # Append prefab if it doesn't contain .prefab on it + name, ext = path.splitext(prefab_path) + if ext != ".prefab": + prefab_path = name + ".prefab" + return prefab_path + + +def get_all_entity_ids(): + return entity.SearchBus(bus.Broadcast, 'SearchEntities', entity.SearchFilter()) + +def wait_for_propagation(): + general.idle_wait_frames(1) # This is a helper class which contains some of the useful information about a prefab instance. class PrefabInstance: - def __init__(self, prefab_file_name: str=None, container_entity: EditorEntity=EntityId()): + def __init__(self, prefab_file_name: str = None, container_entity: EditorEntity = None): self.prefab_file_name: str = prefab_file_name self.container_entity: EditorEntity = container_entity @@ -42,7 +61,7 @@ class PrefabInstance: See if this instance is valid to be used with other prefab operations. :return: Whether the target instance is valid or not. """ - def is_valid() -> bool: + def is_valid(self) -> bool: return self.container_entity.id.IsValid() and self.prefab_file_name in Prefab.existing_prefabs """ @@ -60,7 +79,7 @@ class PrefabInstance: new_parent_before_reparent_children_ids = set(new_parent.get_children_ids()) pyside_utils.run_soon(lambda: self.container_entity.set_parent_entity(parent_entity_id)) - pyside_utils.run_soon(lambda: prefab_test_utils.wait_for_propagation()) + pyside_utils.run_soon(lambda: wait_for_propagation()) try: active_modal_widget = await pyside_utils.wait_for_modal_widget() @@ -94,19 +113,18 @@ class Prefab: existing_prefabs = {} - def __init__(self, file_name: str): - self.file_name:str = file_name - self.file_path: str = prefab_test_utils.get_prefab_file_path(file_name) + def __init__(self, file_path: str): + self.file_path: str = get_prefab_file_path(file_path) self.instances: set[PrefabInstance] = set() """ Check if a prefab is ready to be used to generate its instances. - :param file_name: A unique file name of the target prefab. + :param file_path: A unique file path of the target prefab. :return: Whether the target prefab is loaded or not. """ @classmethod - def is_prefab_loaded(cls, file_name: str) -> bool: - return file_name in Prefab.existing_prefabs + def is_prefab_loaded(cls, file_path: str) -> bool: + return file_path in Prefab.existing_prefabs """ Check if a prefab exists in the directory for files of prefab tests. @@ -114,9 +132,8 @@ class Prefab: :return: Whether the target prefab exists or not. """ @classmethod - def prefab_exists(cls, file_name: str) -> bool: - file_path = prefab_test_utils.get_prefab_file_path(file_name) - return path.exists(file_path) + def prefab_exists(cls, file_path: str) -> bool: + return path.exists(get_prefab_file_path(file_path)) """ Return a prefab which can be used immediately. @@ -125,10 +142,11 @@ class Prefab: """ @classmethod def get_prefab(cls, file_name: str) -> Prefab: + assert file_name, "Received an empty file_name" if Prefab.is_prefab_loaded(file_name): return Prefab.existing_prefabs[file_name] else: - assert Prefab.prefab_exists(file_name), f"Attempted to get a prefab {file_name} that doesn't exist" + assert Prefab.prefab_exists(file_name), f"Attempted to get a prefab \"{file_name}\" that doesn't exist" new_prefab = Prefab(file_name) Prefab.existing_prefabs[file_name] = Prefab(file_name) return new_prefab @@ -141,7 +159,7 @@ class Prefab: :return: Created Prefab object and the very first PrefabInstance object owned by the prefab. """ @classmethod - def create_prefab(cls, entities: list[EditorEntity], file_name: str, prefab_instance_name: str=None) -> (Prefab, PrefabInstance): + def create_prefab(cls, entities: list[EditorEntity], file_name: str, prefab_instance_name: str=None) -> tuple(Prefab, PrefabInstance): assert not Prefab.is_prefab_loaded(file_name), f"Can't create Prefab '{file_name}' since the prefab already exists" new_prefab = Prefab(file_name) @@ -155,7 +173,7 @@ class Prefab: if prefab_instance_name: container_entity.set_name(prefab_instance_name) - prefab_test_utils.wait_for_propagation() + wait_for_propagation() new_prefab_instance = PrefabInstance(file_name, EditorEntity(container_entity_id)) new_prefab.instances.add(new_prefab_instance) @@ -182,12 +200,13 @@ class Prefab: delete_prefab_result = prefab.PrefabPublicRequestBus(bus.Broadcast, 'DeleteEntitiesAndAllDescendantsInInstance', container_entity_ids) assert delete_prefab_result.IsSuccess(), f"Prefab operation 'DeleteEntitiesAndAllDescendantsInInstance' failed. Error: {delete_prefab_result.GetError()}" - prefab_test_utils.wait_for_propagation() + wait_for_propagation() - entity_ids_after_delete = set(prefab_test_utils.get_all_entities()) + entity_ids_after_delete = set(get_all_entity_ids()) + for entity_id_removed in entity_ids_to_remove: if entity_id_removed in entity_ids_after_delete: - assert prefab_entities_deleted, "Not all entities and descendants in target prefabs are deleted." + assert False, "Not all entities and descendants in target prefabs are deleted." for instance in prefab_instances: instance_deleted_prefab = Prefab.get_prefab(instance.prefab_file_name) @@ -215,12 +234,10 @@ class Prefab: if name: container_entity.set_name(name) - prefab_test_utils.wait_for_propagation() + wait_for_propagation() - new_prefab_instance = PrefabInstance(self.file_name, EditorEntity(container_entity_id)) + new_prefab_instance = PrefabInstance(self.file_path, EditorEntity(container_entity_id)) assert not new_prefab_instance in self.instances, "This prefab instance is already existed before this instantiation." self.instances.add(new_prefab_instance) - prefab_test_utils.check_entity_at_position(container_entity_id, prefab_position) - return new_prefab_instance diff --git a/AutomatedTesting/Gem/PythonTests/prefab/TestSuite_Main.py b/AutomatedTesting/Gem/PythonTests/prefab/TestSuite_Main.py index 09df962b0b..30a0055d5a 100644 --- a/AutomatedTesting/Gem/PythonTests/prefab/TestSuite_Main.py +++ b/AutomatedTesting/Gem/PythonTests/prefab/TestSuite_Main.py @@ -29,21 +29,21 @@ class TestAutomation(TestAutomationBase): autotest_mode=autotest_mode) def test_PrefabLevel_OpensLevelWithEntities(self, request, workspace, editor, launcher_platform): - from . import PrefabLevel_OpensLevelWithEntities as test_module + from .tests import PrefabLevel_OpensLevelWithEntities as test_module self._run_prefab_test(request, workspace, editor, test_module) - def test_Prefab_BasicWorkflow_CreatePrefab(self, request, workspace, editor, launcher_platform): - from . import Prefab_BasicWorkflow_CreatePrefab as test_module + def test_PrefabBasicWorkflow_CreatePrefab(self, request, workspace, editor, launcher_platform): + from .tests import PrefabBasicWorkflow_CreatePrefab as test_module self._run_prefab_test(request, workspace, editor, test_module) - def test_Prefab_BasicWorkflow_InstantiatePrefab(self, request, workspace, editor, launcher_platform): - from . import Prefab_BasicWorkflow_InstantiatePrefab as test_module + def test_PrefabBasicWorkflow_InstantiatePrefab(self, request, workspace, editor, launcher_platform): + from .tests import PrefabBasicWorkflow_InstantiatePrefab as test_module self._run_prefab_test(request, workspace, editor, test_module) - def test_Prefab_BasicWorkflow_CreateAndDeletePrefab(self, request, workspace, editor, launcher_platform): - from . import Prefab_BasicWorkflow_CreateAndDeletePrefab as test_module + def test_PrefabBasicWorkflow_CreateAndDeletePrefab(self, request, workspace, editor, launcher_platform): + from .tests import PrefabBasicWorkflow_CreateAndDeletePrefab as test_module self._run_prefab_test(request, workspace, editor, test_module) - def test_Prefab_BasicWorkflow_CreateAndReparentPrefab(self, request, workspace, editor, launcher_platform): - from . import Prefab_BasicWorkflow_CreateAndReparentPrefab as test_module + def test_PrefabBasicWorkflow_CreateAndReparentPrefab(self, request, workspace, editor, launcher_platform): + from .tests import PrefabBasicWorkflow_CreateAndReparentPrefab as test_module self._run_prefab_test(request, workspace, editor, test_module, autotest_mode=False) diff --git a/AutomatedTesting/Gem/PythonTests/prefab/Test.prefab b/AutomatedTesting/Gem/PythonTests/prefab/data/Test.prefab similarity index 100% rename from AutomatedTesting/Gem/PythonTests/prefab/Test.prefab rename to AutomatedTesting/Gem/PythonTests/prefab/data/Test.prefab diff --git a/AutomatedTesting/Gem/PythonTests/prefab/Prefab_BasicWorkflow_CreateAndDeletePrefab.py b/AutomatedTesting/Gem/PythonTests/prefab/tests/PrefabBasicWorkflow_CreateAndDeletePrefab.py similarity index 70% rename from AutomatedTesting/Gem/PythonTests/prefab/Prefab_BasicWorkflow_CreateAndDeletePrefab.py rename to AutomatedTesting/Gem/PythonTests/prefab/tests/PrefabBasicWorkflow_CreateAndDeletePrefab.py index f3fbcfa6ad..9ae4614d80 100644 --- a/AutomatedTesting/Gem/PythonTests/prefab/Prefab_BasicWorkflow_CreateAndDeletePrefab.py +++ b/AutomatedTesting/Gem/PythonTests/prefab/tests/PrefabBasicWorkflow_CreateAndDeletePrefab.py @@ -5,14 +5,14 @@ For complete copyright and license terms please see the LICENSE at the root of t SPDX-License-Identifier: Apache-2.0 OR MIT """ -def Prefab_BasicWorkflow_CreateAndDeletePrefab(): +def PrefabBasicWorkflow_CreateAndDeletePrefab(): CAR_PREFAB_FILE_NAME = 'car_prefab' from editor_python_test_tools.editor_entity_utils import EditorEntity - from prefab.Prefab import Prefab + from editor_python_test_tools.prefab_utils import Prefab - import prefab.Prefab_Test_Utils as prefab_test_utils + import PrefabTestUtils as prefab_test_utils prefab_test_utils.open_base_tests_level() @@ -21,13 +21,13 @@ def Prefab_BasicWorkflow_CreateAndDeletePrefab(): car_entity = EditorEntity.create_editor_entity() car_prefab_entities = [car_entity] - # Checks for prefab creation passed or not + # Asserts if prefab creation doesn't succeeds _, car = Prefab.create_prefab( car_prefab_entities, CAR_PREFAB_FILE_NAME) - # Checks for prefab deletion passed or not + # Asserts if prefab deletion fails Prefab.remove_prefabs([car]) if __name__ == "__main__": from editor_python_test_tools.utils import Report - Report.start_test(Prefab_BasicWorkflow_CreateAndDeletePrefab) + Report.start_test(PrefabBasicWorkflow_CreateAndDeletePrefab) diff --git a/AutomatedTesting/Gem/PythonTests/prefab/Prefab_BasicWorkflow_CreateAndReparentPrefab.py b/AutomatedTesting/Gem/PythonTests/prefab/tests/PrefabBasicWorkflow_CreateAndReparentPrefab.py similarity index 85% rename from AutomatedTesting/Gem/PythonTests/prefab/Prefab_BasicWorkflow_CreateAndReparentPrefab.py rename to AutomatedTesting/Gem/PythonTests/prefab/tests/PrefabBasicWorkflow_CreateAndReparentPrefab.py index e5a9d9930a..f78bbf483d 100644 --- a/AutomatedTesting/Gem/PythonTests/prefab/Prefab_BasicWorkflow_CreateAndReparentPrefab.py +++ b/AutomatedTesting/Gem/PythonTests/prefab/tests/PrefabBasicWorkflow_CreateAndReparentPrefab.py @@ -5,7 +5,7 @@ For complete copyright and license terms please see the LICENSE at the root of t SPDX-License-Identifier: Apache-2.0 OR MIT """ -def Prefab_BasicWorkflow_CreateAndReparentPrefab(): +def PrefabBasicWorkflow_CreateAndReparentPrefab(): CAR_PREFAB_FILE_NAME = 'car_prefab' WHEEL_PREFAB_FILE_NAME = 'wheel_prefab' @@ -16,9 +16,9 @@ def Prefab_BasicWorkflow_CreateAndReparentPrefab(): async def run_test(): from editor_python_test_tools.editor_entity_utils import EditorEntity - from prefab.Prefab import Prefab + from editor_python_test_tools.prefab_utils import Prefab - import prefab.Prefab_Test_Utils as prefab_test_utils + import PrefabTestUtils as prefab_test_utils prefab_test_utils.open_base_tests_level() @@ -46,4 +46,4 @@ def Prefab_BasicWorkflow_CreateAndReparentPrefab(): if __name__ == "__main__": from editor_python_test_tools.utils import Report - Report.start_test(Prefab_BasicWorkflow_CreateAndReparentPrefab) + Report.start_test(PrefabBasicWorkflow_CreateAndReparentPrefab) diff --git a/AutomatedTesting/Gem/PythonTests/prefab/Prefab_BasicWorkflow_CreatePrefab.py b/AutomatedTesting/Gem/PythonTests/prefab/tests/PrefabBasicWorkflow_CreatePrefab.py similarity index 79% rename from AutomatedTesting/Gem/PythonTests/prefab/Prefab_BasicWorkflow_CreatePrefab.py rename to AutomatedTesting/Gem/PythonTests/prefab/tests/PrefabBasicWorkflow_CreatePrefab.py index d86b03d5ad..568a2c15b4 100644 --- a/AutomatedTesting/Gem/PythonTests/prefab/Prefab_BasicWorkflow_CreatePrefab.py +++ b/AutomatedTesting/Gem/PythonTests/prefab/tests/PrefabBasicWorkflow_CreatePrefab.py @@ -5,15 +5,15 @@ For complete copyright and license terms please see the LICENSE at the root of t SPDX-License-Identifier: Apache-2.0 OR MIT """ -def Prefab_BasicWorkflow_CreatePrefab(): +def PrefabBasicWorkflow_CreatePrefab(): CAR_PREFAB_FILE_NAME = 'car_prefab' from editor_python_test_tools.editor_entity_utils import EditorEntity from editor_python_test_tools.utils import Report - from prefab.Prefab import Prefab + from editor_python_test_tools.prefab_utils import Prefab - import prefab.Prefab_Test_Utils as prefab_test_utils + import PrefabTestUtils as prefab_test_utils prefab_test_utils.open_base_tests_level() @@ -27,4 +27,4 @@ def Prefab_BasicWorkflow_CreatePrefab(): if __name__ == "__main__": from editor_python_test_tools.utils import Report - Report.start_test(Prefab_BasicWorkflow_CreatePrefab) + Report.start_test(PrefabBasicWorkflow_CreatePrefab) diff --git a/AutomatedTesting/Gem/PythonTests/prefab/Prefab_BasicWorkflow_InstantiatePrefab.py b/AutomatedTesting/Gem/PythonTests/prefab/tests/PrefabBasicWorkflow_InstantiatePrefab.py similarity index 74% rename from AutomatedTesting/Gem/PythonTests/prefab/Prefab_BasicWorkflow_InstantiatePrefab.py rename to AutomatedTesting/Gem/PythonTests/prefab/tests/PrefabBasicWorkflow_InstantiatePrefab.py index 46be669697..1b962d2ca7 100644 --- a/AutomatedTesting/Gem/PythonTests/prefab/Prefab_BasicWorkflow_InstantiatePrefab.py +++ b/AutomatedTesting/Gem/PythonTests/prefab/tests/PrefabBasicWorkflow_InstantiatePrefab.py @@ -5,17 +5,17 @@ For complete copyright and license terms please see the LICENSE at the root of t SPDX-License-Identifier: Apache-2.0 OR MIT """ -def Prefab_BasicWorkflow_InstantiatePrefab(): +def PrefabBasicWorkflow_InstantiatePrefab(): from azlmbr.math import Vector3 - EXISTING_TEST_PREFAB_FILE_NAME = "Test" + EXISTING_TEST_PREFAB_FILE_NAME = "Gem/PythonTests/Prefab/data/Test.prefab" INSTANTIATED_TEST_PREFAB_POSITION = Vector3(10.00, 20.0, 30.0) EXPECTED_TEST_PREFAB_CHILDREN_COUNT = 1 - from prefab.Prefab import Prefab + from editor_python_test_tools.prefab_utils import Prefab - import prefab.Prefab_Test_Utils as prefab_test_utils + import PrefabTestUtils as prefab_test_utils prefab_test_utils.open_base_tests_level() @@ -31,4 +31,4 @@ def Prefab_BasicWorkflow_InstantiatePrefab(): if __name__ == "__main__": from editor_python_test_tools.utils import Report - Report.start_test(Prefab_BasicWorkflow_InstantiatePrefab) + Report.start_test(PrefabBasicWorkflow_InstantiatePrefab) diff --git a/AutomatedTesting/Gem/PythonTests/prefab/PrefabLevel_OpensLevelWithEntities.py b/AutomatedTesting/Gem/PythonTests/prefab/tests/PrefabLevel_OpensLevelWithEntities.py similarity index 87% rename from AutomatedTesting/Gem/PythonTests/prefab/PrefabLevel_OpensLevelWithEntities.py rename to AutomatedTesting/Gem/PythonTests/prefab/tests/PrefabLevel_OpensLevelWithEntities.py index bc95596845..0eb7e86a9e 100644 --- a/AutomatedTesting/Gem/PythonTests/prefab/PrefabLevel_OpensLevelWithEntities.py +++ b/AutomatedTesting/Gem/PythonTests/prefab/tests/PrefabLevel_OpensLevelWithEntities.py @@ -7,9 +7,9 @@ SPDX-License-Identifier: Apache-2.0 OR MIT # fmt:off class Tests(): - find_empty_entity = ("Entity: 'EmptyEntity' found", "Entity: 'EmptyEntity' *not* found in level") - empty_entity_pos = ("'EmptyEntity' position is at the expected position", "'EmptyEntity' position is *not* at the expected position") - find_pxentity = ("Entity: 'EntityWithPxCollider' found", "Entity: 'EntityWithPxCollider' *not* found in level") + find_empty_entity = ("Entity: 'EmptyEntity' found", "Entity: 'EmptyEntity' *not* found in level") + empty_entity_pos = ("'EmptyEntity' position is at the expected position", "'EmptyEntity' position is *not* at the expected position") + find_pxentity = ("Entity: 'EntityWithPxCollider' found", "Entity: 'EntityWithPxCollider' *not* found in level") pxentity_component = ("Entity: 'EntityWithPxCollider' has a Physx Collider", "Entity: 'EntityWithPxCollider' does *not* have a Physx Collider") # fmt:on diff --git a/AutomatedTesting/Gem/PythonTests/prefab/Prefab_Test_Utils.py b/AutomatedTesting/Gem/PythonTests/prefab/tests/PrefabTestUtils.py similarity index 81% rename from AutomatedTesting/Gem/PythonTests/prefab/Prefab_Test_Utils.py rename to AutomatedTesting/Gem/PythonTests/prefab/tests/PrefabTestUtils.py index 3e19911449..f82af23023 100644 --- a/AutomatedTesting/Gem/PythonTests/prefab/Prefab_Test_Utils.py +++ b/AutomatedTesting/Gem/PythonTests/prefab/tests/PrefabTestUtils.py @@ -18,20 +18,6 @@ import azlmbr.components as components import azlmbr.entity as entity import azlmbr.legacy.general as general -def get_prefab_file_name(prefab_name): - return prefab_name + ".prefab" - -def get_prefab_file_path(prefab_name): - return os.path.join(os.path.dirname(os.path.abspath(__file__)), get_prefab_file_name(prefab_name)) - -def find_entities_by_name(entity_name): - searchFilter = entity.SearchFilter() - searchFilter.names = [entity_name] - return entity.SearchBus(bus.Broadcast, 'SearchEntities', searchFilter) - -def get_all_entities(): - return entity.SearchBus(bus.Broadcast, 'SearchEntities', entity.SearchFilter()) - def check_entity_at_position(entity_id, expected_entity_position): entity_at_expected_position_result = ( "entity is at expected position", @@ -74,9 +60,6 @@ def get_children_ids_by_name(entity_id, entity_name): return result -def wait_for_propagation(): - general.idle_wait_frames(1) - def open_base_tests_level(): helper.init_idle() helper.open_level("Prefab", "Base") diff --git a/Code/Editor/CryEditPy.cpp b/Code/Editor/CryEditPy.cpp index 427737335c..a25a497a4e 100644 --- a/Code/Editor/CryEditPy.cpp +++ b/Code/Editor/CryEditPy.cpp @@ -398,6 +398,11 @@ inline namespace Commands { return AZ::Debug::Trace::WaitForDebugger(timeoutSeconds); } + + AZStd::string PyGetFileAlias(AZStd::string alias) + { + return AZ::IO::FileIOBase::GetInstance()->GetAlias(alias.c_str()); + } } namespace AzToolsFramework @@ -448,6 +453,8 @@ namespace AzToolsFramework addLegacyGeneral(behaviorContext->Method("attach_debugger", PyAttachDebugger, nullptr, "Prompts for attaching the debugger")); addLegacyGeneral(behaviorContext->Method("wait_for_debugger", PyWaitForDebugger, behaviorContext->MakeDefaultValues(-1.f), "Pauses this thread execution until the debugger has been attached")); + addLegacyGeneral(behaviorContext->Method("get_file_alias", PyGetFileAlias, nullptr, "Retrieves path for IO alias")); + // this will put these methods into the 'azlmbr.legacy.checkout_dialog' module auto addCheckoutDialog = [](AZ::BehaviorContext::GlobalMethodBuilder methodBuilder) {