From 36a5beaa7b6f2ac084f3cef546a2f9077e481d12 Mon Sep 17 00:00:00 2001 From: Ondrej Samohel Date: Mon, 24 Apr 2023 12:05:10 +0200 Subject: [PATCH] :bug: few fixes --- openpype/hosts/unreal/api/pipeline.py | 2 +- openpype/hosts/unreal/lib.py | 38 +++++++++++++++++++++++---- 2 files changed, 34 insertions(+), 6 deletions(-) diff --git a/openpype/hosts/unreal/api/pipeline.py b/openpype/hosts/unreal/api/pipeline.py index 0d8922d2e6..bb45fa8c01 100644 --- a/openpype/hosts/unreal/api/pipeline.py +++ b/openpype/hosts/unreal/api/pipeline.py @@ -439,7 +439,7 @@ def create_container(container: str, path: str) -> unreal.Object: ) """ - factory = unreal.AssetContainerFactory() + factory = unreal.AyonAssetContainerFactory() tools = unreal.AssetToolsHelpers().get_asset_tools() return tools.create_asset(container, path, None, factory) diff --git a/openpype/hosts/unreal/lib.py b/openpype/hosts/unreal/lib.py index aa5b09fda8..38976c3ef1 100644 --- a/openpype/hosts/unreal/lib.py +++ b/openpype/hosts/unreal/lib.py @@ -317,18 +317,46 @@ def get_path_to_uat(engine_path: Path) -> Path: if platform.system().lower() == "windows": return engine_path / "Engine/Build/BatchFiles/RunUAT.bat" - if platform.system().lower() == "linux" \ - or platform.system().lower() == "darwin": + if platform.system().lower() in ["linux", "darwin"]: return engine_path / "Engine/Build/BatchFiles/RunUAT.sh" def get_path_to_cmdlet_project(ue_version: str) -> Path: - cmd_project = Path(os.path.dirname( - os.path.abspath(os.getenv("OPENPYPE_ROOT")))) + cmd_project = Path( + os.path.abspath(os.getenv("OPENPYPE_ROOT"))) # For now, only tested on Windows (For Linux and Mac # it has to be implemented) - cmd_project /= f"hosts/unreal/integration/UE_{ue_version}" + cmd_project /= f"openpype/hosts/unreal/integration/UE_{ue_version}" + + # if the integration doesn't exist for current engine version + # try to find the closest to it. + if cmd_project.exists(): + return cmd_project / "CommandletProject/CommandletProject.uproject" + + major, minor = ue_version.split(".") + integration_paths = [p for p in cmd_project.parent.iterdir() + if p.is_dir()] + + compatible_versions = [cmd_project] + for i in integration_paths: + + # parse version from path + i_major, i_minor = re.search( + r"(?P\d+).(?P\d+)$", i.name).groups() + + # consider versions with different major so different that they + # are incompatible + if int(major) != int(i_major): + continue + + compatible_versions.append(i) + + sorted(set(compatible_versions)) + + + + return cmd_project / "CommandletProject/CommandletProject.uproject"