From a2c9834a06af62e0e77501d36c792792e79dbc18 Mon Sep 17 00:00:00 2001 From: Olivier Argentieri Date: Fri, 8 Apr 2022 20:19:50 -0400 Subject: [PATCH 1/3] Changes for UE5.0.0 --- plugins/basic/bootstrap.py | 6 ++++++ .../python/tk_unreal_basic/plugin_bootstrap.py | 4 ++-- python/tk_unreal/unreal_sg_engine.py | 14 +++++++------- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/plugins/basic/bootstrap.py b/plugins/basic/bootstrap.py index b1c1918..9709647 100644 --- a/plugins/basic/bootstrap.py +++ b/plugins/basic/bootstrap.py @@ -9,5 +9,11 @@ plugin_root_dir = os.path.abspath(os.path.dirname(__file__)) sys.path.insert(0, os.path.join(plugin_root_dir, "python")) +# Add sgtk path to sys.path +import pathlib +sgtk_core_path = pathlib.Path(plugin_root_dir.split("app_store")[0]) +sgtk_core_path = sgtk_core_path / "core" / "python" +sys.path.insert(0, str(sgtk_core_path)) + from tk_unreal_basic import plugin_bootstrap plugin_bootstrap.bootstrap_plugin(plugin_root_dir) diff --git a/plugins/basic/python/tk_unreal_basic/plugin_bootstrap.py b/plugins/basic/python/tk_unreal_basic/plugin_bootstrap.py index 9f47317..4c1d665 100644 --- a/plugins/basic/python/tk_unreal_basic/plugin_bootstrap.py +++ b/plugins/basic/python/tk_unreal_basic/plugin_bootstrap.py @@ -47,7 +47,7 @@ def bootstrap_plugin(plugin_root_path): # synchronous manager.bootstrap_engine( - os.environ.get("SHOTGUN_ENGINE", "tk-unreal"), + os.environ.get("SHOTGRID_ENGINE", "tk-unreal"), manager.get_entity_from_environment() ) _on_engine_initialized() @@ -67,7 +67,7 @@ def _on_engine_initialized(): import unreal - unreal.ShotgunEngine.get_instance().on_engine_initialized() + unreal.ShotgridEngine.get_instance().on_engine_initialized() def _initialize_manager(plugin_root_path): diff --git a/python/tk_unreal/unreal_sg_engine.py b/python/tk_unreal/unreal_sg_engine.py index b6bd95d..1aeb193 100644 --- a/python/tk_unreal/unreal_sg_engine.py +++ b/python/tk_unreal/unreal_sg_engine.py @@ -8,10 +8,10 @@ import sys import os -unreal.log("Loading Shotgun Engine for Unreal from {}".format(__file__)) +unreal.log("Loading Shotgrid Engine for Unreal from {}".format(__file__)) @unreal.uclass() -class ShotgunEngineWrapper(unreal.ShotgunEngine): +class ShotgridEngineWrapper(unreal.ShotgridEngine): def _post_init(self): """ @@ -20,23 +20,23 @@ def _post_init(self): config.wrapper_instance = self @unreal.ufunction(override=True) - def get_shotgun_menu_items(self): + def get_shotgrid_menu_items(self): """ - Returns the list of available menu items to populate the Shotgun menu in Unreal + Returns the list of available menu items to populate the Shotgrid menu in Unreal """ menu_items = [] engine = sgtk.platform.current_engine() menu_items = self.create_menu(engine) - unreal.log("get_shotgun_menu_items returned: {0}".format(menu_items.__str__())) + unreal.log("get_shotgrid_menu_items returned: {0}".format(menu_items.__str__())) return menu_items @unreal.ufunction(override=True) def execute_command(self, command_name): """ - Callback to execute the menu item selected in the Shotgun menu in Unreal + Callback to execute the menu item selected in the Shotgrid menu in Unreal """ engine = sgtk.platform.current_engine() @@ -255,7 +255,7 @@ def _add_menu_item(self, menu_items, type, name = "", title = "", description = """ Adds a new Unreal ShotgunMenuItem to the menu items """ - menu_item = unreal.ShotgunMenuItem() + menu_item = unreal.ShotgridMenuItem() menu_item.title = title menu_item.name = name menu_item.type = type From dd8ff644fb47faea5eeb6fe6337f0e8cb87e9d4b Mon Sep 17 00:00:00 2001 From: Olivier Argentieri Date: Fri, 8 Apr 2022 20:23:43 -0400 Subject: [PATCH 2/3] Update plugin_bootstrap.py --- plugins/basic/python/tk_unreal_basic/plugin_bootstrap.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/basic/python/tk_unreal_basic/plugin_bootstrap.py b/plugins/basic/python/tk_unreal_basic/plugin_bootstrap.py index 4c1d665..3c3f7aa 100644 --- a/plugins/basic/python/tk_unreal_basic/plugin_bootstrap.py +++ b/plugins/basic/python/tk_unreal_basic/plugin_bootstrap.py @@ -47,7 +47,7 @@ def bootstrap_plugin(plugin_root_path): # synchronous manager.bootstrap_engine( - os.environ.get("SHOTGRID_ENGINE", "tk-unreal"), + os.environ.get("SHOTGUN_ENGINE", "tk-unreal"), manager.get_entity_from_environment() ) _on_engine_initialized() From ac3758d6befc7da8e0f0653c2f980fe8aae2a725 Mon Sep 17 00:00:00 2001 From: OlivierArgentieri Date: Tue, 3 May 2022 23:43:24 +0200 Subject: [PATCH 3/3] fix useless space --- plugins/basic/python/tk_unreal_basic/plugin_bootstrap.py | 2 +- python/tk_unreal/unreal_sg_engine.py | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/plugins/basic/python/tk_unreal_basic/plugin_bootstrap.py b/plugins/basic/python/tk_unreal_basic/plugin_bootstrap.py index ec3b7c1..3827005 100644 --- a/plugins/basic/python/tk_unreal_basic/plugin_bootstrap.py +++ b/plugins/basic/python/tk_unreal_basic/plugin_bootstrap.py @@ -68,13 +68,13 @@ def _on_engine_initialized(): sgtk_logger.debug("tk-unreal finished initialization.") import unreal - # ShotgunEngine was renamed to ShotgridEngine from UE5 if hasattr(unreal, "ShotgridEngine"): unreal.ShotgridEngine.get_instance().on_engine_initialized() else: unreal.ShotgunEngine.get_instance().on_engine_initialized() + def _initialize_manager(plugin_root_path): """ Initializes a ToolkitManager for use in zero-config mode. diff --git a/python/tk_unreal/unreal_sg_engine.py b/python/tk_unreal/unreal_sg_engine.py index 1fa793f..c803ca4 100644 --- a/python/tk_unreal/unreal_sg_engine.py +++ b/python/tk_unreal/unreal_sg_engine.py @@ -8,15 +8,16 @@ import sys import os - unreal.log("Loading SG Engine for Unreal from {}".format(__file__)) # Shotgun integration components were renamed to Shotgrid from UE5 if hasattr(unreal, "ShotgridEngine"): UESGEngine = unreal.ShotgridEngine + else: UESGEngine = unreal.ShotgunEngine + @unreal.uclass() class ShotgunEngineWrapper(UESGEngine): @@ -313,13 +314,11 @@ def _add_menu_item(self, menu_items, type, name="", title="", description=""): """ Adds a new Unreal SG MenuItem to the menu items. """ - # Shotgun integration components were renamed to Shotgrid from UE5 if hasattr(unreal, "ShotgridMenuItem"): menu_item = unreal.ShotgridMenuItem() else: menu_item = unreal.ShotgunMenuItem() - menu_item.title = title menu_item.name = name menu_item.type = type