Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

Move Unreal Implementation to OpenPype #2823

Merged
merged 11 commits into from
Mar 1, 2022
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
[submodule "repos/avalon-core"]
path = repos/avalon-core
url = https://github.com/pypeclub/avalon-core.git
[submodule "repos/avalon-unreal-integration"]
path = repos/avalon-unreal-integration
url = https://github.com/pypeclub/avalon-unreal-integration.git
url = https://github.com/pypeclub/avalon-core.git
7 changes: 4 additions & 3 deletions openpype/hosts/unreal/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@

def add_implementation_envs(env, _app):
"""Modify environments to contain all required for implementation."""
# Set AVALON_UNREAL_PLUGIN required for Unreal implementation
# Set OPENPYPE_UNREAL_PLUGIN required for Unreal implementation
unreal_plugin_path = os.path.join(
os.environ["OPENPYPE_REPOS_ROOT"], "repos", "avalon-unreal-integration"
os.environ["OPENPYPE_ROOT"], "openpype", "hosts",
antirotor marked this conversation as resolved.
Show resolved Hide resolved
"unreal", "integration"
)
env["AVALON_UNREAL_PLUGIN"] = unreal_plugin_path
env["OPENPYPE_UNREAL_PLUGIN"] = unreal_plugin_path

# Set default environments if are not set via settings
defaults = {
Expand Down
42 changes: 41 additions & 1 deletion openpype/hosts/unreal/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,26 @@
from avalon import api as avalon
from pyblish import api as pyblish
import openpype.hosts.unreal
from .plugin import (
Loader,
Creator
)
from .pipeline import (
install,
uninstall,
ls,
publish,
containerise,
show_creator,
show_loader,
show_publisher,
show_manager,
show_experimental_tools,
show_tools_dialog,
show_tools_popup,
instantiate,
)


logger = logging.getLogger("openpype.hosts.unreal")

Expand All @@ -15,8 +35,28 @@
INVENTORY_PATH = os.path.join(PLUGINS_DIR, "inventory")


__all__ = [
"install",
"uninstall",
"Creator",
"Loader",
"ls",
"publish",
"containerise",
"show_creator",
"show_loader",
"show_publisher",
"show_manager",
"show_experimental_tools",
"show_tools_dialog",
"show_tools_popup",
"instantiate"
]



def install():
antirotor marked this conversation as resolved.
Show resolved Hide resolved
"""Install Unreal configuration for Avalon."""
"""Install Unreal configuration for OpenPype."""
print("-=" * 40)
logo = '''.
.
Expand Down
44 changes: 44 additions & 0 deletions openpype/hosts/unreal/api/helpers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# -*- coding: utf-8 -*-
import unreal # noqa


class OpenPypeUnrealException(Exception):
pass


@unreal.uclass()
class OpenPypeHelpers(unreal.OpenPypeLib):
"""Class wrapping some useful functions for OpenPype.

This class is extending native BP class in OpenPype Integration Plugin.

"""

@unreal.ufunction(params=[str, unreal.LinearColor, bool])
def set_folder_color(self, path: str, color: unreal.LinearColor) -> None:
"""Set color on folder in Content Browser.

This method sets color on folder in Content Browser. Unfortunately
there is no way to refresh Content Browser so new color isn't applied
immediately. They are saved to config file and appears correctly
only after Editor is restarted.

Args:
path (str): Path to folder
color (:class:`unreal.LinearColor`): Color of the folder

Example:

OpenPypeHelpers().set_folder_color(
"/Game/Path", unreal.LinearColor(a=1.0, r=1.0, g=0.5, b=0)
)

Note:
This will take effect only after Editor is restarted. I couldn't
find a way to refresh it. Also this saves the color definition
into the project config, binding this path with color. So if you
delete this path and later re-create, it will set this color
again.

"""
self.c_set_folder_color(path, color, False)
36 changes: 18 additions & 18 deletions openpype/hosts/unreal/api/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,11 +169,11 @@ def create_unreal_project(project_name: str,
env: dict = None) -> None:
"""This will create `.uproject` file at specified location.

As there is no way I know to create project via command line, this is
easiest option. Unreal project file is basically JSON file. If we find
`AVALON_UNREAL_PLUGIN` environment variable we assume this is location
of Avalon Integration Plugin and we copy its content to project folder
and enable this plugin.
As there is no way I know to create a project via command line, this is
easiest option. Unreal project file is basically a JSON file. If we find
the `OPENPYPE_UNREAL_PLUGIN` environment variable we assume this is the
location of the Integration Plugin and we copy its content to the project
folder and enable this plugin.

Args:
project_name (str): Name of the project.
Expand Down Expand Up @@ -230,18 +230,18 @@ def create_unreal_project(project_name: str,
ue_id = "{" + loaded_modules.get("BuildId") + "}"

plugins_path = None
if os.path.isdir(env.get("AVALON_UNREAL_PLUGIN", "")):
if os.path.isdir(env.get("OPENPYPE_UNREAL_PLUGIN", "")):
# copy plugin to correct path under project
plugins_path = pr_dir / "Plugins"
avalon_plugin_path = plugins_path / "Avalon"
if not avalon_plugin_path.is_dir():
avalon_plugin_path.mkdir(parents=True, exist_ok=True)
openpype_plugin_path = plugins_path / "OpenPype"
if not openpype_plugin_path.is_dir():
openpype_plugin_path.mkdir(parents=True, exist_ok=True)
dir_util._path_created = {}
dir_util.copy_tree(os.environ.get("AVALON_UNREAL_PLUGIN"),
avalon_plugin_path.as_posix())
dir_util.copy_tree(os.environ.get("OPENPYPE_UNREAL_PLUGIN"),
openpype_plugin_path.as_posix())

if not (avalon_plugin_path / "Binaries").is_dir() \
or not (avalon_plugin_path / "Intermediate").is_dir():
if not (openpype_plugin_path / "Binaries").is_dir() \
or not (openpype_plugin_path / "Intermediate").is_dir():
dev_mode = True

# data for project file
Expand All @@ -254,14 +254,14 @@ def create_unreal_project(project_name: str,
{"Name": "PythonScriptPlugin", "Enabled": True},
{"Name": "EditorScriptingUtilities", "Enabled": True},
{"Name": "SequencerScripting", "Enabled": True},
{"Name": "Avalon", "Enabled": True}
{"Name": "OpenPype", "Enabled": True}
]
}

if dev_mode or preset["dev_mode"]:
# this will add project module and necessary source file to make it
# C++ project and to (hopefully) make Unreal Editor to compile all
# sources at start
# this will add the project module and necessary source file to
# make it a C++ project and to (hopefully) make Unreal Editor to
# compile all # sources at start

data["Modules"] = [{
"Name": project_name,
Expand Down Expand Up @@ -304,7 +304,7 @@ def _prepare_cpp_project(project_file: Path, engine_path: Path) -> None:
"""Prepare CPP Unreal Project.

This function will add source files needed for project to be
rebuild along with the avalon integration plugin.
rebuild along with the OpenPype integration plugin.

There seems not to be automated way to do it from command line.
But there might be way to create at least those target and build files
Expand Down
Loading