Skip to content

Commit 7a3feb0

Browse files
authored
For #8196, fix for Unreal paths (#8)
Use the project context to retrieve installed Unreal paths rather than the current context. Catch the `TankMissingEngineError` in the UI so users can still set a path manually if there is no Unreal engine in the project config.
1 parent 07b4f14 commit 7a3feb0

File tree

1 file changed

+24
-7
lines changed

1 file changed

+24
-7
lines changed

hooks/tk-multi-publish2/tk-maya/basic/publish_turntable.py

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -566,11 +566,17 @@ def set_ui_settings(self, widget, settings):
566566
# We do not allow editing multiple items
567567
raise NotImplementedError
568568
cur_settings = settings[0]
569-
unreal_versions = self.get_unreal_versions()
570-
widget.unreal_setup_widget.populate_unreal_versions(
571-
unreal_versions,
572-
cur_settings["Unreal Engine Version"],
573-
)
569+
try:
570+
unreal_versions = self.get_unreal_versions()
571+
widget.unreal_setup_widget.populate_unreal_versions(
572+
unreal_versions,
573+
cur_settings["Unreal Engine Version"],
574+
)
575+
except sgtk.platform.TankMissingEngineError:
576+
self.logger.warning(
577+
"Unable to retrieve existing Unreal versions from an installed TK Unreal Engine"
578+
)
579+
574580
widget.unreal_setup_widget.unreal_engine_widget.set_path(
575581
cur_settings["Unreal Engine Path"]
576582
)
@@ -1480,9 +1486,20 @@ def get_unreal_versions(self):
14801486
:returns: A list of TK software versions.
14811487
"""
14821488

1483-
# Create a launcher for the current context
1489+
# Create a launcher.
1490+
# Since we only care about Unreal paths, we use the current project
1491+
# context to retrieve the paths. Otherwise it would require having a valid
1492+
# tk-unreal context matching the current one.
14841493
engine = sgtk.platform.current_engine()
1485-
software_launcher = sgtk.platform.create_engine_launcher(engine.sgtk, engine.context, "tk-unreal")
1494+
project_context = engine.sgtk.context_from_entity_dictionary(
1495+
engine.context.project
1496+
)
1497+
1498+
software_launcher = sgtk.platform.create_engine_launcher(
1499+
engine.sgtk,
1500+
project_context,
1501+
"tk-unreal"
1502+
)
14861503

14871504
# Discover which versions of Unreal are available
14881505
software_versions = software_launcher.scan_software()

0 commit comments

Comments
 (0)