Skip to content

Commit 6863ca4

Browse files
committed
Updated tk-unreal for UE 4.26 / Python 3.
1 parent b416c12 commit 6863ca4

File tree

5 files changed

+24
-22
lines changed

5 files changed

+24
-22
lines changed

engine.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -124,16 +124,6 @@ def init_qt_app(self):
124124
self._qt_app = QtWidgets.QApplication(sys.argv)
125125
self._qt_app.setQuitOnLastWindowClosed(False)
126126
unreal.log("Created QApplication instance: {0}".format(self._qt_app))
127-
128-
def _app_tick(dt):
129-
QtWidgets.QApplication.processEvents()
130-
131-
tick_handle = unreal.register_slate_post_tick_callback(_app_tick)
132-
133-
def _app_quit():
134-
unreal.unregister_slate_post_tick_callback(tick_handle)
135-
136-
QtWidgets.QApplication.instance().aboutToQuit.connect(_app_quit)
137127
else:
138128
self._qt_app = QtWidgets.QApplication.instance()
139129

hooks/tk-multi-publish2/basic/publish_movie.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -327,10 +327,8 @@ def publish(self, settings, item):
327327

328328
# On windows, ensure the path is utf-8 encoded to avoid issues with
329329
# the shotgun api
330-
upload_path = item.properties.get("publish_path")
330+
upload_path = str(item.properties.get("publish_path"))
331331
unreal.log("upload_path: {}".format(upload_path))
332-
if sys.platform.startswith("win"):
333-
upload_path = upload_path.decode("utf-8")
334332

335333
# Upload the file to SG
336334
self.logger.info("Uploading content...")
@@ -429,7 +427,7 @@ def _unreal_render_sequence_to_movie(self, destination_path, unreal_map_path, se
429427
# Must delete it first, otherwise the Sequencer will add a number in the filename
430428
try:
431429
os.remove(output_filepath)
432-
except OSError, e:
430+
except OSError as e:
433431
self.logger.debug("Couldn't delete {}. The Sequencer won't be able to output the movie to that file.".format(output_filepath))
434432
return False, None
435433

python/tk_unreal/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
# This file has been modified by Epic Games, Inc. and is subject to the license
33
# file included in this repository.
44

5-
import unreal_sg_engine
5+
from . import unreal_sg_engine

python/tk_unreal/unreal_sg_engine.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import unreal
66
import sgtk.platform
7-
import config
7+
from . import config
88
import sys
99
import os
1010

@@ -81,7 +81,11 @@ def _get_context_url(self, engine):
8181

8282
# In case of multi-selection, use the first object in the list
8383
selected_asset = self.selected_assets[0] if self.selected_assets else None
84-
selected_actor = self.selected_actors[0] if self.selected_actors else None
84+
try:
85+
selected_actors = self.get_selected_actors()
86+
except:
87+
selected_actors = self.selected_actors
88+
selected_actor = selected_actors[0] if selected_actors else None
8589

8690
loaded_asset = None
8791
if selected_asset:
@@ -156,7 +160,7 @@ def _execute_within_exception_trap(self):
156160
try:
157161
unreal.log("_execute_within_exception_trap: trying callback {0}".format(self._callback.__str__()))
158162
self._callback()
159-
except Exception, e:
163+
except Exception as e:
160164
current_engine = sgtk.platform.current_engine()
161165
current_engine.logger.exception("An exception was raised from Toolkit")
162166
self._callback = None
@@ -313,8 +317,12 @@ def _add_app_menu(self, commands_by_app, menu_items):
313317
:param commands_by_app: Dictionary of app name and commands related to the app, which
314318
will be added to the menu_items
315319
"""
316-
has_selection = len(self.selected_assets) > 0 or len(self.selected_actors) > 0
317-
320+
try:
321+
has_selected_actors = len(self.get_selected_actors()) > 0
322+
except:
323+
has_selected_actors = len(self.selected_actors) > 0
324+
has_selection = len(self.selected_assets) > 0 or has_selected_actors
325+
318326
for app_name in sorted(commands_by_app.keys()):
319327
# Exclude the Publish app if it doesn't have any context
320328
if app_name == "Publish" and not has_selection:

startup.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,10 @@ def _get_installation_paths_from_registry(logger):
200200
201201
:returns: List of paths where Unreal is installed
202202
"""
203-
import _winreg
203+
try:
204+
import _winreg
205+
except ImportError:
206+
import winreg as _winreg
204207
logger.debug("Querying windows registry for key HKEY_LOCAL_MACHINE\\SOFTWARE\\EpicGames\\Unreal Engine")
205208

206209
base_key_name = "SOFTWARE\\EpicGames\\Unreal Engine"
@@ -241,7 +244,10 @@ def _get_development_builds_paths_from_registry(logger):
241244
242245
:returns: List of paths where Unreal executable is found
243246
"""
244-
import _winreg
247+
try:
248+
import _winreg
249+
except ImportError:
250+
import winreg as _winreg
245251
logger.debug("Querying windows registry for key HKEY_CURRENT_USER\\SOFTWARE\\Epic Games\\Unreal Engine\\Builds")
246252

247253
base_key_name = "SOFTWARE\\Epic Games\\Unreal Engine\\Builds"

0 commit comments

Comments
 (0)