Skip to content

Commit

Permalink
Merge pull request #9 from ue4plugins/gpltech
Browse files Browse the repository at this point in the history
Merging all updates from Gpltech for official release
  • Loading branch information
ryanmayeda authored Apr 29, 2022
2 parents 6863ca4 + 8b7a9e3 commit c562838
Show file tree
Hide file tree
Showing 20 changed files with 1,588 additions and 457 deletions.
44 changes: 44 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Flake 8 PEP and lint configuration - https://gitlab.com/pycqa/flake8
#
# This defines the official lint and PEP8 rules for this repository
#
# You can run this locally by running 'pip install flake8' and then
# >flake8 .

[flake8]

# Things we don't want to lint
exclude =
.tox,
.git,
.flake8,
.gitignore,
.travis.yml,
.cache,
.eggs,
*.rst,
*.yml,
*.pyc,
*.pyo,
*.egg-info,
__pycache__,
# Those are our third parties, do not lint them
vendors,
# Skip __init__.py files, to not have a lot of 'xxx' imported but unused
python/__init__.py,
python/*/__init__.py,
# Skip the auto-generated ui file.
python/*/ui,
venv
winenv

# Ignore some errors
#
# E402 module level import not at top of file
# E501 line too long (112 > 79 characters)
# N802 Variables should be lower case. (clashes with Qt naming conventions)
# N806 Variables should be lower case. (clashes with Qt naming conventions)
# W503 line break before binary operator (it breaks before, not after)

ignore = E501, E402, N802, N806, W503

4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,7 @@ pip-log.txt

# Max OS X Desktop Services Store files
.DS_Store

# Visual Studio
.vs
.vscode
35 changes: 35 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# This file is based on templates provided and copyrighted by Autodesk, Inc.
# This file has been modified by Epic Games, Inc. and is subject to the license
# file included in this repository.

# Styles the code properly
# Exclude the UI files, as they are auto-generated.
exclude: "ui\/.*py$"
# List of super useful formatters.
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.4.0
hooks:
# Ensures the code is syntaxically correct
- id: check-ast
language_version: python3
# Ensures a file name will resolve on all platform
- id: check-case-conflict
# Checks files with the execute bit set have shebangs
- id: check-executables-have-shebangs
# Ensure there's no incomplete merges
- id: check-merge-conflict
# Adds an empty line if missing at the end of a file.
- id: end-of-file-fixer
# Makes sure requirements.txt is properly formatted
- id: requirements-txt-fixer
# Removes trailing whitespaces.
- id: trailing-whitespace
# Leave black at the bottom so all touchups are done before it is run.
- repo: https://github.com/ambv/black
rev: 19.10b0
hooks:
- id: black
language_version: python3


69 changes: 68 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,70 @@
## Documentation

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).
This repository is a part of the ShotGrid Pipeline Toolkit/Unreal integration and contains the source code for SG TK Unreal engine.

The simplest way to add the ShotGrid Toolkit integration to Unreal is to start from the available standard Shotgrid Toolkit configurations:
- Default2 SG TK configuration: https://github.com/ue4plugins/tk-config-unreal
- Basic SG TK configuration: https://github.com/ue4plugins/tk-config-unrealbasic

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).

### Configuring the file system schema for a default2 base configuration
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.
```
schema/
└── project
├── assets
│   └── asset_type
│   └── asset
│   └── step
│   ├── publish
│   │   └── fbx
│   │   └── placeholder
│   └── work
│   └── fbx
│   └── placeholder
└── sequences
└── sequence
└── editorial
└── placeholder
```

### Adding the SG TK Unreal components
Both configs have a self contained `env/includes/unreal` folder which contains all definitions needed by the integration
```
unreal/
├── frameworks.yml
├── settings
│   ├── tk-multi-loader2.yml
│   ├── tk-multi-publish2.yml
│   ├── tk-multi-shotgunpanel.yml
│   └── tk-unreal.yml
├── templates.yml
└── tk-unreal-location.yml
```

This folder should be copied to the `env/includes` folder of your existing configuration.

Then the following files (or similar) need to be modified to add the Unreal integration:

- *core/templates.yml*:
- add `include: ../env/includes/unreal/templates.yml`
- *env/project.yml*:
- add `- ./includes/unreal/settings/tk-unreal.yml` to *includes*
- add `tk-unreal: "@settings.tk-unreal.project"` to *engines*
- *env/asset_step.yml*:
- add `- ./includes/unreal/settings/tk-unreal.yml` to *includes*
- add `tk-unreal: "@settings.tk-unreal.asset_step"` to *engines*
- *env/includes/settings/tk-maya.yml* or *env/includes/maya/asset_step.yml*:
- add `- ../unreal/settings/tk-multi-publish2.yml` to *includes*
- replace *tk-multi-publish2* asset step setting with: `tk-multi-publish2: "@settings.tk-multi-publish2.maya.asset_step.unreal"`
- *env/includes/frameworks* or *env/includes/common/frameworks.yml*:
- add `include: unreal/frameworks.yml`
- *env/includes/settings/tk-desktop.yml* or *env/includes/desktop/project.yml*:
- add "*Unreal*" to Creative Tools group.



## See also:
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).

27 changes: 27 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Python package
# Create and test a Python package on multiple Python versions.
# Add steps that analyze code, save the dist with the build record, publish to a PyPI-compatible index, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/python

# The github_ci_token variable is defined in the Azure Pipeline web page as a
# secret variable and is a github personal token.

jobs:
- job: 'Flake8'
pool:
vmImage: ubuntu-latest

steps:
- task: UsePythonVersion@0
inputs:
versionSpec: 3.7
architecture: 'x64'

- script: |
python -m pip install --upgrade pip setuptools wheel
displayName: 'Install prerequisites'
- script: |
python -m pip install flake8
flake8 .
displayName: 'Run flake8'
63 changes: 35 additions & 28 deletions engine.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# This file is based on templates provided and copyrighted by Autodesk, Inc.
# This file has been modified by Epic Games, Inc. and is subject to the license
# This file has been modified by Epic Games, Inc. and is subject to the license
# file included in this repository.

"""
Expand Down Expand Up @@ -27,21 +27,10 @@
class UnrealEditorEngine(Engine):
"""
Toolkit engine for Unreal.
All the methods that are present are either stubs or example of the expected functionality.
Note that when the engine starts up a log file is created at
Windows: %APPDATA%\Shotgun\logs\tk-unreal.log
macOS: ~/Library/Logs/Shotgun/tk-unreal.log
Linux: ~/.shotgun/logs/tk-unreal.log
and that all logging calls to Toolkit logging methods will be forwarded there.
It all uses the Python's logger under the hood.
"""

metadata_tag_prefix = "SG."

def __init__(self, *args, **kwargs):
"""
Engine Constructor
Expand Down Expand Up @@ -99,7 +88,7 @@ def pre_app_init(self):

self.init_qt_app()

# Load the tk_unreal module (the Shotgun engine wrapper for Unreal)
# Load the tk_unreal module (the SG engine wrapper for Unreal)
self.tk_unreal = self.import_module("tk_unreal")
self.unreal_sg_engine = self.tk_unreal.config.wrapper_instance

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

def init_qt_app(self):
self.logger.debug("%s: Initializing QtApp for Unreal", self)

from sgtk.platform.qt5 import QtWidgets

if not QtWidgets.QApplication.instance():
self._qt_app = QtWidgets.QApplication(sys.argv)
self._qt_app.setQuitOnLastWindowClosed(False)
unreal.log("Created QApplication instance: {0}".format(self._qt_app))
else:
self._qt_app = QtWidgets.QApplication.instance()

# On other platforms than Windows, we need to process the Qt events otherwise
# UIs are "frozen". We use a slate tick callback to do that on a regular basis.
# It is not clear why this is not needed on Windows, possibly because a
# dedicated Windows event dispatcher is used instead of a regular
# QAbstractEventDispatcher
if sys.platform != "win32":
unreal.register_slate_post_tick_callback(self._process_qt_events_cb)
# Make the QApplication use the dark theme. Must be called after the QApplication is instantiated
self._initialize_dark_look_and_feel()


@staticmethod
def _process_qt_events_cb(delta_time):
"""
An Unreal tick callback to process QT events.
:param float delta_time: delta time since the last run.
"""
from sgtk.platform.qt5 import QtWidgets
qapp = QtWidgets.QApplication.instance()
if qapp:
qapp.processEvents()

def post_app_init(self):
"""
Called when all apps have initialized
Expand Down Expand Up @@ -214,10 +220,10 @@ def destroy_engine(self):
"""
self.logger.debug("%s: Destroying tk-unreal engine...", self)

# Close all Shotgun app dialogs that are still opened since
# Close all Shotgun app dialogs that are still opened since
# some apps do threads cleanup in their onClose event handler
# Note that this function is called when the engine is restarted (through "Reload Engine and Apps")

# Important: Copy the list of dialogs still opened since the call to close() will modify created_qt_dialogs
dialogs_still_opened = self.created_qt_dialogs[:]

Expand All @@ -229,7 +235,7 @@ def get_metadata_tag(self, tag):
Returns the given tag with the metadata tag prefix defined for this engine
"""
return UnrealEditorEngine.metadata_tag_prefix + tag

def _get_dialog_parent(self):
"""
Get the QWidget parent for all dialogs created through
Expand Down Expand Up @@ -259,17 +265,18 @@ def _create_dialog(self, title, bundle, widget, parent):
Function override to set the window icon
"""
dialog = sgtk.platform.Engine._create_dialog(self, title, bundle, widget, parent)

from sgtk.platform.qt import QtGui

unreal_icon = os.path.realpath(os.path.join(
os.path.dirname(__file__),
"icon_256.png"))

unreal_icon = os.path.realpath(
os.path.join(
os.path.dirname(__file__),
"icon_256.png"
)
)
dialog.setWindowIcon(QtGui.QIcon(unreal_icon))

return dialog

def _define_qt_base(self):
"""
This will be called at initialisation time and will allow
Expand Down
Loading

0 comments on commit c562838

Please sign in to comment.