Skip to content

Commit c562838

Browse files
authored
Merge pull request #9 from ue4plugins/gpltech
Merging all updates from Gpltech for official release
2 parents 6863ca4 + 8b7a9e3 commit c562838

File tree

20 files changed

+1588
-457
lines changed

20 files changed

+1588
-457
lines changed

.flake8

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Flake 8 PEP and lint configuration - https://gitlab.com/pycqa/flake8
2+
#
3+
# This defines the official lint and PEP8 rules for this repository
4+
#
5+
# You can run this locally by running 'pip install flake8' and then
6+
# >flake8 .
7+
8+
[flake8]
9+
10+
# Things we don't want to lint
11+
exclude =
12+
.tox,
13+
.git,
14+
.flake8,
15+
.gitignore,
16+
.travis.yml,
17+
.cache,
18+
.eggs,
19+
*.rst,
20+
*.yml,
21+
*.pyc,
22+
*.pyo,
23+
*.egg-info,
24+
__pycache__,
25+
# Those are our third parties, do not lint them
26+
vendors,
27+
# Skip __init__.py files, to not have a lot of 'xxx' imported but unused
28+
python/__init__.py,
29+
python/*/__init__.py,
30+
# Skip the auto-generated ui file.
31+
python/*/ui,
32+
venv
33+
winenv
34+
35+
# Ignore some errors
36+
#
37+
# E402 module level import not at top of file
38+
# E501 line too long (112 > 79 characters)
39+
# N802 Variables should be lower case. (clashes with Qt naming conventions)
40+
# N806 Variables should be lower case. (clashes with Qt naming conventions)
41+
# W503 line break before binary operator (it breaks before, not after)
42+
43+
ignore = E501, E402, N802, N806, W503
44+

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,7 @@ pip-log.txt
3131

3232
# Max OS X Desktop Services Store files
3333
.DS_Store
34+
35+
# Visual Studio
36+
.vs
37+
.vscode

.pre-commit-config.yaml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# This file is based on templates provided and copyrighted by Autodesk, Inc.
2+
# This file has been modified by Epic Games, Inc. and is subject to the license
3+
# file included in this repository.
4+
5+
# Styles the code properly
6+
# Exclude the UI files, as they are auto-generated.
7+
exclude: "ui\/.*py$"
8+
# List of super useful formatters.
9+
repos:
10+
- repo: https://github.com/pre-commit/pre-commit-hooks
11+
rev: v2.4.0
12+
hooks:
13+
# Ensures the code is syntaxically correct
14+
- id: check-ast
15+
language_version: python3
16+
# Ensures a file name will resolve on all platform
17+
- id: check-case-conflict
18+
# Checks files with the execute bit set have shebangs
19+
- id: check-executables-have-shebangs
20+
# Ensure there's no incomplete merges
21+
- id: check-merge-conflict
22+
# Adds an empty line if missing at the end of a file.
23+
- id: end-of-file-fixer
24+
# Makes sure requirements.txt is properly formatted
25+
- id: requirements-txt-fixer
26+
# Removes trailing whitespaces.
27+
- id: trailing-whitespace
28+
# Leave black at the bottom so all touchups are done before it is run.
29+
- repo: https://github.com/ambv/black
30+
rev: 19.10b0
31+
hooks:
32+
- id: black
33+
language_version: python3
34+
35+

README.md

Lines changed: 68 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,70 @@
11
## Documentation
22

3-
For more information on how to run the Shotgun/Unreal integration, please see the [support documentation](https://docs.unrealengine.com/en-us/Editor/Content/Using-Unreal-Engine-with-Autodesk-Shotgun).
3+
This repository is a part of the ShotGrid Pipeline Toolkit/Unreal integration and contains the source code for SG TK Unreal engine.
4+
5+
The simplest way to add the ShotGrid Toolkit integration to Unreal is to start from the available standard Shotgrid Toolkit configurations:
6+
- Default2 SG TK configuration: https://github.com/ue4plugins/tk-config-unreal
7+
- Basic SG TK configuration: https://github.com/ue4plugins/tk-config-unrealbasic
8+
9+
However, it is possible to manually add the integration to an existing SG TK configuration from the files provided by the [default2 based Unreal config](https://github.com/ue4plugins/tk-config-unreal) or the [basic based Unreal config](https://github.com/ue4plugins/tk-config-unrealbasic).
10+
11+
### Configuring the file system schema for a default2 base configuration
12+
If your SG TK configuration needs a file system schema, copy the following files and directories from `core/schema` of [this config](https://github.com/ue4plugins/tk-config-unreal) under the `core/schema` folder of your existing configuration.
13+
```
14+
schema/
15+
└── project
16+
├── assets
17+
│   └── asset_type
18+
│   └── asset
19+
│   └── step
20+
│   ├── publish
21+
│   │   └── fbx
22+
│   │   └── placeholder
23+
│   └── work
24+
│   └── fbx
25+
│   └── placeholder
26+
└── sequences
27+
└── sequence
28+
└── editorial
29+
└── placeholder
30+
```
31+
32+
### Adding the SG TK Unreal components
33+
Both configs have a self contained `env/includes/unreal` folder which contains all definitions needed by the integration
34+
```
35+
unreal/
36+
├── frameworks.yml
37+
├── settings
38+
│   ├── tk-multi-loader2.yml
39+
│   ├── tk-multi-publish2.yml
40+
│   ├── tk-multi-shotgunpanel.yml
41+
│   └── tk-unreal.yml
42+
├── templates.yml
43+
└── tk-unreal-location.yml
44+
```
45+
46+
This folder should be copied to the `env/includes` folder of your existing configuration.
47+
48+
Then the following files (or similar) need to be modified to add the Unreal integration:
49+
50+
- *core/templates.yml*:
51+
- add `include: ../env/includes/unreal/templates.yml`
52+
- *env/project.yml*:
53+
- add `- ./includes/unreal/settings/tk-unreal.yml` to *includes*
54+
- add `tk-unreal: "@settings.tk-unreal.project"` to *engines*
55+
- *env/asset_step.yml*:
56+
- add `- ./includes/unreal/settings/tk-unreal.yml` to *includes*
57+
- add `tk-unreal: "@settings.tk-unreal.asset_step"` to *engines*
58+
- *env/includes/settings/tk-maya.yml* or *env/includes/maya/asset_step.yml*:
59+
- add `- ../unreal/settings/tk-multi-publish2.yml` to *includes*
60+
- replace *tk-multi-publish2* asset step setting with: `tk-multi-publish2: "@settings.tk-multi-publish2.maya.asset_step.unreal"`
61+
- *env/includes/frameworks* or *env/includes/common/frameworks.yml*:
62+
- add `include: unreal/frameworks.yml`
63+
- *env/includes/settings/tk-desktop.yml* or *env/includes/desktop/project.yml*:
64+
- add "*Unreal*" to Creative Tools group.
65+
66+
67+
68+
## See also:
69+
For more information on how to run the ShotGrid/Unreal integration, please see the [support documentation](https://docs.unrealengine.com/4.27/en-US/ProductionPipelines/UsingUnrealEnginewithAutodeskShotGrid).
70+

azure-pipelines.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Python package
2+
# Create and test a Python package on multiple Python versions.
3+
# Add steps that analyze code, save the dist with the build record, publish to a PyPI-compatible index, and more:
4+
# https://docs.microsoft.com/azure/devops/pipelines/languages/python
5+
6+
# The github_ci_token variable is defined in the Azure Pipeline web page as a
7+
# secret variable and is a github personal token.
8+
9+
jobs:
10+
- job: 'Flake8'
11+
pool:
12+
vmImage: ubuntu-latest
13+
14+
steps:
15+
- task: UsePythonVersion@0
16+
inputs:
17+
versionSpec: 3.7
18+
architecture: 'x64'
19+
20+
- script: |
21+
python -m pip install --upgrade pip setuptools wheel
22+
displayName: 'Install prerequisites'
23+
24+
- script: |
25+
python -m pip install flake8
26+
flake8 .
27+
displayName: 'Run flake8'

engine.py

Lines changed: 35 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# This file is based on templates provided and copyrighted by Autodesk, Inc.
2-
# This file has been modified by Epic Games, Inc. and is subject to the license
2+
# This file has been modified by Epic Games, Inc. and is subject to the license
33
# file included in this repository.
44

55
"""
@@ -27,21 +27,10 @@
2727
class UnrealEditorEngine(Engine):
2828
"""
2929
Toolkit engine for Unreal.
30-
31-
All the methods that are present are either stubs or example of the expected functionality.
32-
33-
Note that when the engine starts up a log file is created at
34-
35-
Windows: %APPDATA%\Shotgun\logs\tk-unreal.log
36-
macOS: ~/Library/Logs/Shotgun/tk-unreal.log
37-
Linux: ~/.shotgun/logs/tk-unreal.log
38-
39-
and that all logging calls to Toolkit logging methods will be forwarded there.
40-
It all uses the Python's logger under the hood.
4130
"""
4231

4332
metadata_tag_prefix = "SG."
44-
33+
4534
def __init__(self, *args, **kwargs):
4635
"""
4736
Engine Constructor
@@ -99,7 +88,7 @@ def pre_app_init(self):
9988

10089
self.init_qt_app()
10190

102-
# Load the tk_unreal module (the Shotgun engine wrapper for Unreal)
91+
# Load the tk_unreal module (the SG engine wrapper for Unreal)
10392
self.tk_unreal = self.import_module("tk_unreal")
10493
self.unreal_sg_engine = self.tk_unreal.config.wrapper_instance
10594

@@ -117,19 +106,36 @@ def init_engine(self):
117106

118107
def init_qt_app(self):
119108
self.logger.debug("%s: Initializing QtApp for Unreal", self)
120-
121109
from sgtk.platform.qt5 import QtWidgets
122-
110+
123111
if not QtWidgets.QApplication.instance():
124112
self._qt_app = QtWidgets.QApplication(sys.argv)
125113
self._qt_app.setQuitOnLastWindowClosed(False)
126-
unreal.log("Created QApplication instance: {0}".format(self._qt_app))
127114
else:
128115
self._qt_app = QtWidgets.QApplication.instance()
129116

117+
# On other platforms than Windows, we need to process the Qt events otherwise
118+
# UIs are "frozen". We use a slate tick callback to do that on a regular basis.
119+
# It is not clear why this is not needed on Windows, possibly because a
120+
# dedicated Windows event dispatcher is used instead of a regular
121+
# QAbstractEventDispatcher
122+
if sys.platform != "win32":
123+
unreal.register_slate_post_tick_callback(self._process_qt_events_cb)
130124
# Make the QApplication use the dark theme. Must be called after the QApplication is instantiated
131125
self._initialize_dark_look_and_feel()
132-
126+
127+
@staticmethod
128+
def _process_qt_events_cb(delta_time):
129+
"""
130+
An Unreal tick callback to process QT events.
131+
132+
:param float delta_time: delta time since the last run.
133+
"""
134+
from sgtk.platform.qt5 import QtWidgets
135+
qapp = QtWidgets.QApplication.instance()
136+
if qapp:
137+
qapp.processEvents()
138+
133139
def post_app_init(self):
134140
"""
135141
Called when all apps have initialized
@@ -214,10 +220,10 @@ def destroy_engine(self):
214220
"""
215221
self.logger.debug("%s: Destroying tk-unreal engine...", self)
216222

217-
# Close all Shotgun app dialogs that are still opened since
223+
# Close all Shotgun app dialogs that are still opened since
218224
# some apps do threads cleanup in their onClose event handler
219225
# Note that this function is called when the engine is restarted (through "Reload Engine and Apps")
220-
226+
221227
# Important: Copy the list of dialogs still opened since the call to close() will modify created_qt_dialogs
222228
dialogs_still_opened = self.created_qt_dialogs[:]
223229

@@ -229,7 +235,7 @@ def get_metadata_tag(self, tag):
229235
Returns the given tag with the metadata tag prefix defined for this engine
230236
"""
231237
return UnrealEditorEngine.metadata_tag_prefix + tag
232-
238+
233239
def _get_dialog_parent(self):
234240
"""
235241
Get the QWidget parent for all dialogs created through
@@ -259,17 +265,18 @@ def _create_dialog(self, title, bundle, widget, parent):
259265
Function override to set the window icon
260266
"""
261267
dialog = sgtk.platform.Engine._create_dialog(self, title, bundle, widget, parent)
262-
268+
263269
from sgtk.platform.qt import QtGui
264270

265-
unreal_icon = os.path.realpath(os.path.join(
266-
os.path.dirname(__file__),
267-
"icon_256.png"))
268-
271+
unreal_icon = os.path.realpath(
272+
os.path.join(
273+
os.path.dirname(__file__),
274+
"icon_256.png"
275+
)
276+
)
269277
dialog.setWindowIcon(QtGui.QIcon(unreal_icon))
270-
271278
return dialog
272-
279+
273280
def _define_qt_base(self):
274281
"""
275282
This will be called at initialisation time and will allow

0 commit comments

Comments
 (0)