Skip to content

Commit

Permalink
Updated tk-unreal for UE 4.26 / Python 3.
Browse files Browse the repository at this point in the history
  • Loading branch information
akitisa-epic committed Dec 10, 2020
1 parent b416c12 commit 6863ca4
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 22 deletions.
10 changes: 0 additions & 10 deletions engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,16 +124,6 @@ def init_qt_app(self):
self._qt_app = QtWidgets.QApplication(sys.argv)
self._qt_app.setQuitOnLastWindowClosed(False)
unreal.log("Created QApplication instance: {0}".format(self._qt_app))

def _app_tick(dt):
QtWidgets.QApplication.processEvents()

tick_handle = unreal.register_slate_post_tick_callback(_app_tick)

def _app_quit():
unreal.unregister_slate_post_tick_callback(tick_handle)

QtWidgets.QApplication.instance().aboutToQuit.connect(_app_quit)
else:
self._qt_app = QtWidgets.QApplication.instance()

Expand Down
6 changes: 2 additions & 4 deletions hooks/tk-multi-publish2/basic/publish_movie.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,10 +327,8 @@ def publish(self, settings, item):

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

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

Expand Down
2 changes: 1 addition & 1 deletion python/tk_unreal/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
# This file has been modified by Epic Games, Inc. and is subject to the license
# file included in this repository.

import unreal_sg_engine
from . import unreal_sg_engine
18 changes: 13 additions & 5 deletions python/tk_unreal/unreal_sg_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import unreal
import sgtk.platform
import config
from . import config
import sys
import os

Expand Down Expand Up @@ -81,7 +81,11 @@ def _get_context_url(self, engine):

# In case of multi-selection, use the first object in the list
selected_asset = self.selected_assets[0] if self.selected_assets else None
selected_actor = self.selected_actors[0] if self.selected_actors else None
try:
selected_actors = self.get_selected_actors()
except:
selected_actors = self.selected_actors
selected_actor = selected_actors[0] if selected_actors else None

loaded_asset = None
if selected_asset:
Expand Down Expand Up @@ -156,7 +160,7 @@ def _execute_within_exception_trap(self):
try:
unreal.log("_execute_within_exception_trap: trying callback {0}".format(self._callback.__str__()))
self._callback()
except Exception, e:
except Exception as e:
current_engine = sgtk.platform.current_engine()
current_engine.logger.exception("An exception was raised from Toolkit")
self._callback = None
Expand Down Expand Up @@ -313,8 +317,12 @@ def _add_app_menu(self, commands_by_app, menu_items):
:param commands_by_app: Dictionary of app name and commands related to the app, which
will be added to the menu_items
"""
has_selection = len(self.selected_assets) > 0 or len(self.selected_actors) > 0

try:
has_selected_actors = len(self.get_selected_actors()) > 0
except:
has_selected_actors = len(self.selected_actors) > 0
has_selection = len(self.selected_assets) > 0 or has_selected_actors

for app_name in sorted(commands_by_app.keys()):
# Exclude the Publish app if it doesn't have any context
if app_name == "Publish" and not has_selection:
Expand Down
10 changes: 8 additions & 2 deletions startup.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,10 @@ def _get_installation_paths_from_registry(logger):
:returns: List of paths where Unreal is installed
"""
import _winreg
try:
import _winreg
except ImportError:
import winreg as _winreg
logger.debug("Querying windows registry for key HKEY_LOCAL_MACHINE\\SOFTWARE\\EpicGames\\Unreal Engine")

base_key_name = "SOFTWARE\\EpicGames\\Unreal Engine"
Expand Down Expand Up @@ -241,7 +244,10 @@ def _get_development_builds_paths_from_registry(logger):
:returns: List of paths where Unreal executable is found
"""
import _winreg
try:
import _winreg
except ImportError:
import winreg as _winreg
logger.debug("Querying windows registry for key HKEY_CURRENT_USER\\SOFTWARE\\Epic Games\\Unreal Engine\\Builds")

base_key_name = "SOFTWARE\\Epic Games\\Unreal Engine\\Builds"
Expand Down

0 comments on commit 6863ca4

Please sign in to comment.