From 713b82b19c6fe6c4bae7fcc57bdd3662e30eecc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Samohel?= Date: Tue, 1 Mar 2022 11:32:03 +0100 Subject: [PATCH] renaming integration --- .gitmodules | 5 +- openpype/hosts/unreal/api/__init__.py | 2 +- openpype/hosts/unreal/api/helpers.py | 2 +- openpype/hosts/unreal/api/lib.py | 18 ++--- openpype/hosts/unreal/api/pipeline.py | 74 ++++++++----------- .../unreal/hooks/pre_workfile_preparation.py | 4 +- .../integration/Content/Python/init_unreal.py | 31 ++++---- .../Private/AvalonPublishInstanceFactory.cpp | 20 ----- .../Avalon/Private/AvalonPythonBridge.cpp | 13 ---- .../Source/Avalon/Private/AvalonStyle.cpp | 69 ----------------- .../OpenPype.Build.cs} | 2 +- .../Private/AssetContainer.cpp | 0 .../Private/AssetContainerFactory.cpp | 0 .../Private/OpenPype.cpp} | 46 ++++++------ .../Private/OpenPypeLib.cpp} | 6 +- .../Private/OpenPypePublishInstance.cpp} | 30 ++++---- .../OpenPypePublishInstanceFactory.cpp | 20 +++++ .../OpenPype/Private/OpenPypePythonBridge.cpp | 13 ++++ .../Source/OpenPype/Private/OpenPypeStyle.cpp | 70 ++++++++++++++++++ .../Public/AssetContainer.h | 0 .../Public/AssetContainerFactory.h | 2 +- .../Avalon.h => OpenPype/Public/OpenPype.h} | 2 +- .../Public/OpenPypeLib.h} | 2 +- .../Public/OpenPypePublishInstance.h} | 6 +- .../Public/OpenPypePublishInstanceFactory.h} | 6 +- .../Public/OpenPypePythonBridge.h} | 6 +- .../Public/OpenPypeStyle.h} | 2 +- .../unreal/plugins/create/create_camera.py | 2 +- .../unreal/plugins/create/create_layout.py | 3 +- .../unreal/plugins/create/create_look.py | 14 ++-- .../plugins/create/create_staticmeshfbx.py | 8 +- .../load/load_alembic_geometrycache.py | 22 +++--- .../plugins/load/load_alembic_skeletalmesh.py | 19 ++--- .../plugins/load/load_alembic_staticmesh.py | 21 +++--- .../unreal/plugins/load/load_animation.py | 24 +++--- .../hosts/unreal/plugins/load/load_camera.py | 16 ++-- .../hosts/unreal/plugins/load/load_layout.py | 49 ++++++------ .../hosts/unreal/plugins/load/load_rig.py | 25 ++++--- .../unreal/plugins/load/load_staticmeshfbx.py | 26 ++++--- .../plugins/publish/collect_current_file.py | 9 ++- .../plugins/publish/collect_instances.py | 10 ++- .../unreal/plugins/publish/extract_camera.py | 8 +- .../unreal/plugins/publish/extract_layout.py | 7 +- .../unreal/plugins/publish/extract_look.py | 15 ++-- 44 files changed, 376 insertions(+), 353 deletions(-) delete mode 100644 openpype/hosts/unreal/integration/Source/Avalon/Private/AvalonPublishInstanceFactory.cpp delete mode 100644 openpype/hosts/unreal/integration/Source/Avalon/Private/AvalonPythonBridge.cpp delete mode 100644 openpype/hosts/unreal/integration/Source/Avalon/Private/AvalonStyle.cpp rename openpype/hosts/unreal/integration/Source/{Avalon/Avalon.Build.cs => OpenPype/OpenPype.Build.cs} (96%) rename openpype/hosts/unreal/integration/Source/{Avalon => OpenPype}/Private/AssetContainer.cpp (100%) rename openpype/hosts/unreal/integration/Source/{Avalon => OpenPype}/Private/AssetContainerFactory.cpp (100%) rename openpype/hosts/unreal/integration/Source/{Avalon/Private/Avalon.cpp => OpenPype/Private/OpenPype.cpp} (56%) rename openpype/hosts/unreal/integration/Source/{Avalon/Private/AvalonLib.cpp => OpenPype/Private/OpenPypeLib.cpp} (84%) rename openpype/hosts/unreal/integration/Source/{Avalon/Private/AvalonPublishInstance.cpp => OpenPype/Private/OpenPypePublishInstance.cpp} (67%) create mode 100644 openpype/hosts/unreal/integration/Source/OpenPype/Private/OpenPypePublishInstanceFactory.cpp create mode 100644 openpype/hosts/unreal/integration/Source/OpenPype/Private/OpenPypePythonBridge.cpp create mode 100644 openpype/hosts/unreal/integration/Source/OpenPype/Private/OpenPypeStyle.cpp rename openpype/hosts/unreal/integration/Source/{Avalon => OpenPype}/Public/AssetContainer.h (100%) rename openpype/hosts/unreal/integration/Source/{Avalon => OpenPype}/Public/AssetContainerFactory.h (89%) rename openpype/hosts/unreal/integration/Source/{Avalon/Public/Avalon.h => OpenPype/Public/OpenPype.h} (87%) rename openpype/hosts/unreal/integration/Source/{Avalon/Public/AvalonLib.h => OpenPype/Public/OpenPypeLib.h} (88%) rename openpype/hosts/unreal/integration/Source/{Avalon/Public/AvalonPublishInstance.h => OpenPype/Public/OpenPypePublishInstance.h} (65%) rename openpype/hosts/unreal/integration/Source/{Avalon/Public/AvalonPublishInstanceFactory.h => OpenPype/Public/OpenPypePublishInstanceFactory.h} (61%) rename openpype/hosts/unreal/integration/Source/{Avalon/Public/AvalonPythonBridge.h => OpenPype/Public/OpenPypePythonBridge.h} (71%) rename openpype/hosts/unreal/integration/Source/{Avalon/Public/AvalonStyle.h => OpenPype/Public/OpenPypeStyle.h} (95%) diff --git a/.gitmodules b/.gitmodules index 67b820a247..9920ceaad6 100644 --- a/.gitmodules +++ b/.gitmodules @@ -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 \ No newline at end of file + url = https://github.com/pypeclub/avalon-core.git \ No newline at end of file diff --git a/openpype/hosts/unreal/api/__init__.py b/openpype/hosts/unreal/api/__init__.py index 38469e0ddb..df86c09073 100644 --- a/openpype/hosts/unreal/api/__init__.py +++ b/openpype/hosts/unreal/api/__init__.py @@ -16,7 +16,7 @@ INVENTORY_PATH = os.path.join(PLUGINS_DIR, "inventory") def install(): - """Install Unreal configuration for Avalon.""" + """Install Unreal configuration for OpenPype.""" print("-=" * 40) logo = '''. . diff --git a/openpype/hosts/unreal/api/helpers.py b/openpype/hosts/unreal/api/helpers.py index 6fc89cf176..555133eae0 100644 --- a/openpype/hosts/unreal/api/helpers.py +++ b/openpype/hosts/unreal/api/helpers.py @@ -29,7 +29,7 @@ class OpenPypeHelpers(unreal.OpenPypeLib): Example: - AvalonHelpers().set_folder_color( + OpenPypeHelpers().set_folder_color( "/Game/Path", unreal.LinearColor(a=1.0, r=1.0, g=0.5, b=0) ) diff --git a/openpype/hosts/unreal/api/lib.py b/openpype/hosts/unreal/api/lib.py index e04606a333..d4a776e892 100644 --- a/openpype/hosts/unreal/api/lib.py +++ b/openpype/hosts/unreal/api/lib.py @@ -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 @@ -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 diff --git a/openpype/hosts/unreal/api/pipeline.py b/openpype/hosts/unreal/api/pipeline.py index c255005f31..02c89abadd 100644 --- a/openpype/hosts/unreal/api/pipeline.py +++ b/openpype/hosts/unreal/api/pipeline.py @@ -1,21 +1,17 @@ # -*- coding: utf-8 -*- -import sys import pyblish.api from avalon.pipeline import AVALON_CONTAINER_ID import unreal # noqa from typing import List - from openpype.tools.utils import host_tools - from avalon import api -AVALON_CONTAINERS = "OpenPypeContainers" +OPENPYPE_CONTAINERS = "OpenPypeContainers" def install(): - pyblish.api.register_host("unreal") _register_callbacks() _register_events() @@ -46,7 +42,7 @@ class Creator(api.Creator): def process(self): nodes = list() - with unreal.ScopedEditorTransaction("Avalon Creating Instance"): + with unreal.ScopedEditorTransaction("OpenPype Creating Instance"): if (self.options or {}).get("useSelection"): self.log.info("setting ...") print("settings ...") @@ -63,23 +59,21 @@ class Creator(api.Creator): return instance -class Loader(api.Loader): - hosts = ["unreal"] - - def ls(): - """ - List all containers found in *Content Manager* of Unreal and return + """List all containers. + + List all found in *Content Manager* of Unreal and return metadata from them. Adding `objectName` to set. + """ ar = unreal.AssetRegistryHelpers.get_asset_registry() - avalon_containers = ar.get_assets_by_class("AssetContainer", True) + openpype_containers = ar.get_assets_by_class("AssetContainer", True) # get_asset_by_class returns AssetData. To get all metadata we need to # load asset. get_tag_values() work only on metadata registered in - # Asset Registy Project settings (and there is no way to set it with + # Asset Registry Project settings (and there is no way to set it with # python short of editing ini configuration file). - for asset_data in avalon_containers: + for asset_data in openpype_containers: asset = asset_data.get_asset() data = unreal.EditorAssetLibrary.get_metadata_tag_values(asset) data["objectName"] = asset_data.asset_name @@ -89,8 +83,7 @@ def ls(): def parse_container(container): - """ - To get data from container, AssetContainer must be loaded. + """To get data from container, AssetContainer must be loaded. Args: container(str): path to container @@ -107,20 +100,19 @@ def parse_container(container): def publish(): - """Shorthand to publish from within host""" + """Shorthand to publish from within host.""" import pyblish.util return pyblish.util.publish() def containerise(name, namespace, nodes, context, loader=None, suffix="_CON"): - """Bundles *nodes* (assets) into a *container* and add metadata to it. Unreal doesn't support *groups* of assets that you can add metadata to. But it does support folders that helps to organize asset. Unfortunately those folders are just that - you cannot add any additional information - to them. `Avalon Integration Plugin`_ is providing way out - Implementing + to them. OpenPype Integration Plugin is providing way out - Implementing `AssetContainer` Blueprint class. This class when added to folder can handle metadata on it using standard :func:`unreal.EditorAssetLibrary.set_metadata_tag()` and @@ -129,10 +121,7 @@ def containerise(name, namespace, nodes, context, loader=None, suffix="_CON"): those assets is available as `assets` property. This is list of strings starting with asset type and ending with its path: - `Material /Game/Avalon/Test/TestMaterial.TestMaterial` - - .. _Avalon Integration Plugin: - https://github.com/pypeclub/avalon-unreal-integration + `Material /Game/OpenPype/Test/TestMaterial.TestMaterial` """ # 1 - create directory for container @@ -160,10 +149,11 @@ def containerise(name, namespace, nodes, context, loader=None, suffix="_CON"): def instantiate(root, name, data, assets=None, suffix="_INS"): - """ - Bundles *nodes* into *container* marking it with metadata as publishable - instance. If assets are provided, they are moved to new path where - `AvalonPublishInstance` class asset is created and imprinted with metadata. + """Bundles *nodes* into *container*. + + Marking it with metadata as publishable instance. If assets are provided, + they are moved to new path where `OpenPypePublishInstance` class asset is + created and imprinted with metadata. This can then be collected for publishing by Pyblish for example. @@ -174,6 +164,7 @@ def instantiate(root, name, data, assets=None, suffix="_INS"): assets (list of str): list of asset paths to include in publish instance suffix (str): suffix string to append to instance name + """ container_name = "{}{}".format(name, suffix) @@ -203,7 +194,7 @@ def imprint(node, data): loaded_asset, key, str(value) ) - with unreal.ScopedEditorTransaction("Avalon containerising"): + with unreal.ScopedEditorTransaction("OpenPype containerising"): unreal.EditorAssetLibrary.save_asset(node) @@ -248,7 +239,7 @@ def show_experimental_tools(): def create_folder(root: str, name: str) -> str: - """Create new folder + """Create new folder. If folder exists, append number at the end and try again, incrementing if needed. @@ -281,8 +272,7 @@ def create_folder(root: str, name: str) -> str: def move_assets_to_path(root: str, name: str, assets: List[str]) -> str: - """ - Moving (renaming) list of asset paths to new destination. + """Moving (renaming) list of asset paths to new destination. Args: root (str): root of the path (eg. `/Game`) @@ -316,8 +306,8 @@ def move_assets_to_path(root: str, name: str, assets: List[str]) -> str: def create_container(container: str, path: str) -> unreal.Object: - """ - Helper function to create Asset Container class on given path. + """Helper function to create Asset Container class on given path. + This Asset Class helps to mark given path as Container and enable asset version control on it. @@ -331,7 +321,7 @@ def create_container(container: str, path: str) -> unreal.Object: Example: - create_avalon_container( + create_container( "/Game/modelingFooCharacter_CON", "modelingFooCharacter_CON" ) @@ -345,9 +335,9 @@ def create_container(container: str, path: str) -> unreal.Object: def create_publish_instance(instance: str, path: str) -> unreal.Object: - """ - Helper function to create Avalon Publish Instance on given path. - This behaves similary as :func:`create_avalon_container`. + """Helper function to create OpenPype Publish Instance on given path. + + This behaves similarly as :func:`create_openpype_container`. Args: path (str): Path where to create Publish Instance. @@ -365,13 +355,13 @@ def create_publish_instance(instance: str, path: str) -> unreal.Object: ) """ - factory = unreal.AvalonPublishInstanceFactory() + factory = unreal.OpenPypePublishInstanceFactory() tools = unreal.AssetToolsHelpers().get_asset_tools() asset = tools.create_asset(instance, path, None, factory) return asset -def cast_map_to_str_dict(map) -> dict: +def cast_map_to_str_dict(umap) -> dict: """Cast Unreal Map to dict. Helper function to cast Unreal Map object to plain old python @@ -379,10 +369,10 @@ def cast_map_to_str_dict(map) -> dict: metadata dicts. Args: - map: Unreal Map object + umap: Unreal Map object Returns: dict """ - return {str(key): str(value) for (key, value) in map.items()} + return {str(key): str(value) for (key, value) in umap.items()} diff --git a/openpype/hosts/unreal/hooks/pre_workfile_preparation.py b/openpype/hosts/unreal/hooks/pre_workfile_preparation.py index 880dba5cfb..6b787f4da7 100644 --- a/openpype/hosts/unreal/hooks/pre_workfile_preparation.py +++ b/openpype/hosts/unreal/hooks/pre_workfile_preparation.py @@ -136,9 +136,9 @@ class UnrealPrelaunchHook(PreLaunchHook): f"{self.signature} creating unreal " f"project [ {unreal_project_name} ]" )) - # Set "AVALON_UNREAL_PLUGIN" to current process environment for + # Set "OPENPYPE_UNREAL_PLUGIN" to current process environment for # execution of `create_unreal_project` - env_key = "AVALON_UNREAL_PLUGIN" + env_key = "OPENPYPE_UNREAL_PLUGIN" if self.launch_context.env.get(env_key): os.environ[env_key] = self.launch_context.env[env_key] diff --git a/openpype/hosts/unreal/integration/Content/Python/init_unreal.py b/openpype/hosts/unreal/integration/Content/Python/init_unreal.py index 48e931bb04..4445abb1b0 100644 --- a/openpype/hosts/unreal/integration/Content/Python/init_unreal.py +++ b/openpype/hosts/unreal/integration/Content/Python/init_unreal.py @@ -1,27 +1,32 @@ import unreal -avalon_detected = True +openpype_detected = True try: from avalon import api - from avalon import unreal as avalon_unreal except ImportError as exc: - avalon_detected = False - unreal.log_error("Avalon: cannot load avalon [ {} ]".format(exc)) + openpype_detected = False + unreal.log_error("Avalon: cannot load Avalon [ {} ]".format(exc)) -if avalon_detected: - api.install(avalon_unreal) +try: + from openpype.host.unreal import api as openpype_host +except ImportError as exc: + openpype_detected = False + unreal.log_error("OpenPype: cannot load OpenPype [ {} ]".format(exc)) + +if openpype_detected: + api.install(openpype_host) @unreal.uclass() -class AvalonIntegration(unreal.AvalonPythonBridge): +class OpenPypeIntegration(unreal.OpenPypePythonBridge): @unreal.ufunction(override=True) def RunInPython_Popup(self): - unreal.log_warning("Avalon: showing tools popup") - if avalon_detected: - avalon_unreal.show_tools_popup() + unreal.log_warning("OpenPype: showing tools popup") + if openpype_detected: + openpype_host.show_tools_popup() @unreal.ufunction(override=True) def RunInPython_Dialog(self): - unreal.log_warning("Avalon: showing tools dialog") - if avalon_detected: - avalon_unreal.show_tools_dialog() + unreal.log_warning("OpenPype: showing tools dialog") + if openpype_detected: + openpype_host.show_tools_dialog() diff --git a/openpype/hosts/unreal/integration/Source/Avalon/Private/AvalonPublishInstanceFactory.cpp b/openpype/hosts/unreal/integration/Source/Avalon/Private/AvalonPublishInstanceFactory.cpp deleted file mode 100644 index e14a14f1e5..0000000000 --- a/openpype/hosts/unreal/integration/Source/Avalon/Private/AvalonPublishInstanceFactory.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include "AvalonPublishInstanceFactory.h" -#include "AvalonPublishInstance.h" - -UAvalonPublishInstanceFactory::UAvalonPublishInstanceFactory(const FObjectInitializer& ObjectInitializer) - : UFactory(ObjectInitializer) -{ - SupportedClass = UAvalonPublishInstance::StaticClass(); - bCreateNew = false; - bEditorImport = true; -} - -UObject* UAvalonPublishInstanceFactory::FactoryCreateNew(UClass* Class, UObject* InParent, FName Name, EObjectFlags Flags, UObject* Context, FFeedbackContext* Warn) -{ - UAvalonPublishInstance* AvalonPublishInstance = NewObject(InParent, Class, Name, Flags); - return AvalonPublishInstance; -} - -bool UAvalonPublishInstanceFactory::ShouldShowInNewMenu() const { - return false; -} diff --git a/openpype/hosts/unreal/integration/Source/Avalon/Private/AvalonPythonBridge.cpp b/openpype/hosts/unreal/integration/Source/Avalon/Private/AvalonPythonBridge.cpp deleted file mode 100644 index 8642ab6b63..0000000000 --- a/openpype/hosts/unreal/integration/Source/Avalon/Private/AvalonPythonBridge.cpp +++ /dev/null @@ -1,13 +0,0 @@ -#include "AvalonPythonBridge.h" - -UAvalonPythonBridge* UAvalonPythonBridge::Get() -{ - TArray AvalonPythonBridgeClasses; - GetDerivedClasses(UAvalonPythonBridge::StaticClass(), AvalonPythonBridgeClasses); - int32 NumClasses = AvalonPythonBridgeClasses.Num(); - if (NumClasses > 0) - { - return Cast(AvalonPythonBridgeClasses[NumClasses - 1]->GetDefaultObject()); - } - return nullptr; -}; \ No newline at end of file diff --git a/openpype/hosts/unreal/integration/Source/Avalon/Private/AvalonStyle.cpp b/openpype/hosts/unreal/integration/Source/Avalon/Private/AvalonStyle.cpp deleted file mode 100644 index 5b3d1269b0..0000000000 --- a/openpype/hosts/unreal/integration/Source/Avalon/Private/AvalonStyle.cpp +++ /dev/null @@ -1,69 +0,0 @@ -#include "AvalonStyle.h" -#include "Framework/Application/SlateApplication.h" -#include "Styling/SlateStyle.h" -#include "Styling/SlateStyleRegistry.h" - - -TUniquePtr< FSlateStyleSet > FAvalonStyle::AvalonStyleInstance = nullptr; - -void FAvalonStyle::Initialize() -{ - if (!AvalonStyleInstance.IsValid()) - { - AvalonStyleInstance = Create(); - FSlateStyleRegistry::RegisterSlateStyle(*AvalonStyleInstance); - } -} - -void FAvalonStyle::Shutdown() -{ - if (AvalonStyleInstance.IsValid()) - { - FSlateStyleRegistry::UnRegisterSlateStyle(*AvalonStyleInstance); - AvalonStyleInstance.Reset(); - } -} - -FName FAvalonStyle::GetStyleSetName() -{ - static FName StyleSetName(TEXT("AvalonStyle")); - return StyleSetName; -} - -FName FAvalonStyle::GetContextName() -{ - static FName ContextName(TEXT("OpenPype")); - return ContextName; -} - -#define IMAGE_BRUSH(RelativePath, ...) FSlateImageBrush( Style->RootToContentDir( RelativePath, TEXT(".png") ), __VA_ARGS__ ) - -const FVector2D Icon40x40(40.0f, 40.0f); - -TUniquePtr< FSlateStyleSet > FAvalonStyle::Create() -{ - TUniquePtr< FSlateStyleSet > Style = MakeUnique(GetStyleSetName()); - Style->SetContentRoot(FPaths::ProjectPluginsDir() / TEXT("Avalon/Resources")); - - return Style; -} - -void FAvalonStyle::SetIcon(const FString& StyleName, const FString& ResourcePath) -{ - FSlateStyleSet* Style = AvalonStyleInstance.Get(); - - FString Name(GetContextName().ToString()); - Name = Name + "." + StyleName; - Style->Set(*Name, new FSlateImageBrush(Style->RootToContentDir(ResourcePath, TEXT(".png")), Icon40x40)); - - - FSlateApplication::Get().GetRenderer()->ReloadTextureResources(); -} - -#undef IMAGE_BRUSH - -const ISlateStyle& FAvalonStyle::Get() -{ - check(AvalonStyleInstance); - return *AvalonStyleInstance; -} diff --git a/openpype/hosts/unreal/integration/Source/Avalon/Avalon.Build.cs b/openpype/hosts/unreal/integration/Source/OpenPype/OpenPype.Build.cs similarity index 96% rename from openpype/hosts/unreal/integration/Source/Avalon/Avalon.Build.cs rename to openpype/hosts/unreal/integration/Source/OpenPype/OpenPype.Build.cs index 5068e37d80..cf50041aed 100644 --- a/openpype/hosts/unreal/integration/Source/Avalon/Avalon.Build.cs +++ b/openpype/hosts/unreal/integration/Source/OpenPype/OpenPype.Build.cs @@ -2,7 +2,7 @@ using UnrealBuildTool; -public class Avalon : ModuleRules +public class OpenPype : ModuleRules { public Avalon(ReadOnlyTargetRules Target) : base(Target) { diff --git a/openpype/hosts/unreal/integration/Source/Avalon/Private/AssetContainer.cpp b/openpype/hosts/unreal/integration/Source/OpenPype/Private/AssetContainer.cpp similarity index 100% rename from openpype/hosts/unreal/integration/Source/Avalon/Private/AssetContainer.cpp rename to openpype/hosts/unreal/integration/Source/OpenPype/Private/AssetContainer.cpp diff --git a/openpype/hosts/unreal/integration/Source/Avalon/Private/AssetContainerFactory.cpp b/openpype/hosts/unreal/integration/Source/OpenPype/Private/AssetContainerFactory.cpp similarity index 100% rename from openpype/hosts/unreal/integration/Source/Avalon/Private/AssetContainerFactory.cpp rename to openpype/hosts/unreal/integration/Source/OpenPype/Private/AssetContainerFactory.cpp diff --git a/openpype/hosts/unreal/integration/Source/Avalon/Private/Avalon.cpp b/openpype/hosts/unreal/integration/Source/OpenPype/Private/OpenPype.cpp similarity index 56% rename from openpype/hosts/unreal/integration/Source/Avalon/Private/Avalon.cpp rename to openpype/hosts/unreal/integration/Source/OpenPype/Private/OpenPype.cpp index ed782f4870..65da780ad6 100644 --- a/openpype/hosts/unreal/integration/Source/Avalon/Private/Avalon.cpp +++ b/openpype/hosts/unreal/integration/Source/OpenPype/Private/OpenPype.cpp @@ -1,19 +1,19 @@ #include "Avalon.h" #include "LevelEditor.h" -#include "AvalonPythonBridge.h" -#include "AvalonStyle.h" +#include "OpenPypePythonBridge.h" +#include "OpenPypeStyle.h" -static const FName AvalonTabName("Avalon"); +static const FName OpenPypeTabName("OpenPype"); -#define LOCTEXT_NAMESPACE "FAvalonModule" +#define LOCTEXT_NAMESPACE "FOpenPypeModule" // This function is triggered when the plugin is staring up -void FAvalonModule::StartupModule() +void FOpenPypeModule::StartupModule() { - FAvalonStyle::Initialize(); - FAvalonStyle::SetIcon("Logo", "openpype40"); + FOpenPypeStyle::Initialize(); + FOpenPypeStyle::SetIcon("Logo", "openpype40"); // Create the Extender that will add content to the menu FLevelEditorModule& LevelEditorModule = FModuleManager::LoadModuleChecked("LevelEditor"); @@ -25,13 +25,13 @@ void FAvalonModule::StartupModule() "LevelEditor", EExtensionHook::After, NULL, - FMenuExtensionDelegate::CreateRaw(this, &FAvalonModule::AddMenuEntry) + FMenuExtensionDelegate::CreateRaw(this, &FOpenPypeModule::AddMenuEntry) ); ToolbarExtender->AddToolBarExtension( "Settings", EExtensionHook::After, NULL, - FToolBarExtensionDelegate::CreateRaw(this, &FAvalonModule::AddToobarEntry)); + FToolBarExtensionDelegate::CreateRaw(this, &FOpenPypeModule::AddToobarEntry)); LevelEditorModule.GetMenuExtensibilityManager()->AddExtender(MenuExtender); @@ -39,13 +39,13 @@ void FAvalonModule::StartupModule() } -void FAvalonModule::ShutdownModule() +void FOpenPypeModule::ShutdownModule() { - FAvalonStyle::Shutdown(); + FOpenPypeStyle::Shutdown(); } -void FAvalonModule::AddMenuEntry(FMenuBuilder& MenuBuilder) +void FOpenPypeModule::AddMenuEntry(FMenuBuilder& MenuBuilder) { // Create Section MenuBuilder.BeginSection("OpenPype", TAttribute(FText::FromString("OpenPype"))); @@ -54,22 +54,22 @@ void FAvalonModule::AddMenuEntry(FMenuBuilder& MenuBuilder) MenuBuilder.AddMenuEntry( FText::FromString("Tools..."), FText::FromString("Pipeline tools"), - FSlateIcon(FAvalonStyle::GetStyleSetName(), "OpenPype.Logo"), - FUIAction(FExecuteAction::CreateRaw(this, &FAvalonModule::MenuPopup)) + FSlateIcon(FOpenPypeStyle::GetStyleSetName(), "OpenPype.Logo"), + FUIAction(FExecuteAction::CreateRaw(this, &FOpenPypeModule::MenuPopup)) ); MenuBuilder.AddMenuEntry( FText::FromString("Tools dialog..."), FText::FromString("Pipeline tools dialog"), - FSlateIcon(FAvalonStyle::GetStyleSetName(), "OpenPype.Logo"), - FUIAction(FExecuteAction::CreateRaw(this, &FAvalonModule::MenuDialog)) + FSlateIcon(FOpenPypeStyle::GetStyleSetName(), "OpenPype.Logo"), + FUIAction(FExecuteAction::CreateRaw(this, &FOpenPypeModule::MenuDialog)) ); } MenuBuilder.EndSection(); } -void FAvalonModule::AddToobarEntry(FToolBarBuilder& ToolbarBuilder) +void FOpenPypeModule::AddToobarEntry(FToolBarBuilder& ToolbarBuilder) { ToolbarBuilder.BeginSection(TEXT("OpenPype")); { @@ -83,21 +83,21 @@ void FAvalonModule::AddToobarEntry(FToolBarBuilder& ToolbarBuilder) NAME_None, LOCTEXT("OpenPype_label", "OpenPype"), LOCTEXT("OpenPype_tooltip", "OpenPype Tools"), - FSlateIcon(FAvalonStyle::GetStyleSetName(), "OpenPype.Logo") + FSlateIcon(FOpenPypeStyle::GetStyleSetName(), "OpenPype.Logo") ); } ToolbarBuilder.EndSection(); } -void FAvalonModule::MenuPopup() { - UAvalonPythonBridge* bridge = UAvalonPythonBridge::Get(); +void FOpenPypeModule::MenuPopup() { + UOpenPypePythonBridge* bridge = UOpenPypePythonBridge::Get(); bridge->RunInPython_Popup(); } -void FAvalonModule::MenuDialog() { - UAvalonPythonBridge* bridge = UAvalonPythonBridge::Get(); +void FOpenPypeModule::MenuDialog() { + UOpenPypePythonBridge* bridge = UOpenPypePythonBridge::Get(); bridge->RunInPython_Dialog(); } -IMPLEMENT_MODULE(FAvalonModule, Avalon) +IMPLEMENT_MODULE(FOpenPypeModule, OpenPype) diff --git a/openpype/hosts/unreal/integration/Source/Avalon/Private/AvalonLib.cpp b/openpype/hosts/unreal/integration/Source/OpenPype/Private/OpenPypeLib.cpp similarity index 84% rename from openpype/hosts/unreal/integration/Source/Avalon/Private/AvalonLib.cpp rename to openpype/hosts/unreal/integration/Source/OpenPype/Private/OpenPypeLib.cpp index 312656424c..5facab7b8b 100644 --- a/openpype/hosts/unreal/integration/Source/Avalon/Private/AvalonLib.cpp +++ b/openpype/hosts/unreal/integration/Source/OpenPype/Private/OpenPypeLib.cpp @@ -1,4 +1,4 @@ -#include "AvalonLib.h" +#include "OpenPypeLib.h" #include "Misc/Paths.h" #include "Misc/ConfigCacheIni.h" #include "UObject/UnrealType.h" @@ -10,7 +10,7 @@ * @warning This color will appear only after Editor restart. Is there a better way? */ -void UAvalonLib::CSetFolderColor(FString FolderPath, FLinearColor FolderColor, bool bForceAdd) +void UOpenPypeLib::CSetFolderColor(FString FolderPath, FLinearColor FolderColor, bool bForceAdd) { auto SaveColorInternal = [](FString InPath, FLinearColor InFolderColor) { @@ -30,7 +30,7 @@ void UAvalonLib::CSetFolderColor(FString FolderPath, FLinearColor FolderColor, b * @param cls - class * @return TArray of properties */ -TArray UAvalonLib::GetAllProperties(UClass* cls) +TArray UOpenPypeLib::GetAllProperties(UClass* cls) { TArray Ret; if (cls != nullptr) diff --git a/openpype/hosts/unreal/integration/Source/Avalon/Private/AvalonPublishInstance.cpp b/openpype/hosts/unreal/integration/Source/OpenPype/Private/OpenPypePublishInstance.cpp similarity index 67% rename from openpype/hosts/unreal/integration/Source/Avalon/Private/AvalonPublishInstance.cpp rename to openpype/hosts/unreal/integration/Source/OpenPype/Private/OpenPypePublishInstance.cpp index 2bb31a4853..4f1e846c0b 100644 --- a/openpype/hosts/unreal/integration/Source/Avalon/Private/AvalonPublishInstance.cpp +++ b/openpype/hosts/unreal/integration/Source/OpenPype/Private/OpenPypePublishInstance.cpp @@ -1,28 +1,28 @@ #pragma once -#include "AvalonPublishInstance.h" +#include "OpenPypePublishInstance.h" #include "AssetRegistryModule.h" -UAvalonPublishInstance::UAvalonPublishInstance(const FObjectInitializer& ObjectInitializer) +UOpenPypePublishInstance::UOpenPypePublishInstance(const FObjectInitializer& ObjectInitializer) : UObject(ObjectInitializer) { FAssetRegistryModule& AssetRegistryModule = FModuleManager::LoadModuleChecked("AssetRegistry"); - FString path = UAvalonPublishInstance::GetPathName(); + FString path = UOpenPypePublishInstance::GetPathName(); FARFilter Filter; Filter.PackagePaths.Add(FName(*path)); - AssetRegistryModule.Get().OnAssetAdded().AddUObject(this, &UAvalonPublishInstance::OnAssetAdded); - AssetRegistryModule.Get().OnAssetRemoved().AddUObject(this, &UAvalonPublishInstance::OnAssetRemoved); - AssetRegistryModule.Get().OnAssetRenamed().AddUObject(this, &UAvalonPublishInstance::OnAssetRenamed); + AssetRegistryModule.Get().OnAssetAdded().AddUObject(this, &UOpenPypePublishInstance::OnAssetAdded); + AssetRegistryModule.Get().OnAssetRemoved().AddUObject(this, &UOpenPypePublishInstance::OnAssetRemoved); + AssetRegistryModule.Get().OnAssetRenamed().AddUObject(this, &UOpenPypePublishInstance::OnAssetRenamed); } -void UAvalonPublishInstance::OnAssetAdded(const FAssetData& AssetData) +void UOpenPypePublishInstance::OnAssetAdded(const FAssetData& AssetData) { TArray split; // get directory of current container - FString selfFullPath = UAvalonPublishInstance::GetPathName(); + FString selfFullPath = UOpenPypePublishInstance::GetPathName(); FString selfDir = FPackageName::GetLongPackagePath(*selfFullPath); // get asset path and class @@ -38,7 +38,7 @@ void UAvalonPublishInstance::OnAssetAdded(const FAssetData& AssetData) if (assetDir.StartsWith(*selfDir)) { // exclude self - if (assetFName != "AvalonPublishInstance") + if (assetFName != "OpenPypePublishInstance") { assets.Add(assetPath); UE_LOG(LogTemp, Log, TEXT("%s: asset added to %s"), *selfFullPath, *selfDir); @@ -46,12 +46,12 @@ void UAvalonPublishInstance::OnAssetAdded(const FAssetData& AssetData) } } -void UAvalonPublishInstance::OnAssetRemoved(const FAssetData& AssetData) +void UOpenPypePublishInstance::OnAssetRemoved(const FAssetData& AssetData) { TArray split; // get directory of current container - FString selfFullPath = UAvalonPublishInstance::GetPathName(); + FString selfFullPath = UOpenPypePublishInstance::GetPathName(); FString selfDir = FPackageName::GetLongPackagePath(*selfFullPath); // get asset path and class @@ -64,13 +64,13 @@ void UAvalonPublishInstance::OnAssetRemoved(const FAssetData& AssetData) FString assetDir = FPackageName::GetLongPackagePath(*split[1]); // take interest only in paths starting with path of current container - FString path = UAvalonPublishInstance::GetPathName(); + FString path = UOpenPypePublishInstance::GetPathName(); FString lpp = FPackageName::GetLongPackagePath(*path); if (assetDir.StartsWith(*selfDir)) { // exclude self - if (assetFName != "AvalonPublishInstance") + if (assetFName != "OpenPypePublishInstance") { // UE_LOG(LogTemp, Warning, TEXT("%s: asset removed"), *lpp); assets.Remove(assetPath); @@ -78,12 +78,12 @@ void UAvalonPublishInstance::OnAssetRemoved(const FAssetData& AssetData) } } -void UAvalonPublishInstance::OnAssetRenamed(const FAssetData& AssetData, const FString& str) +void UOpenPypePublishInstance::OnAssetRenamed(const FAssetData& AssetData, const FString& str) { TArray split; // get directory of current container - FString selfFullPath = UAvalonPublishInstance::GetPathName(); + FString selfFullPath = UOpenPypePublishInstance::GetPathName(); FString selfDir = FPackageName::GetLongPackagePath(*selfFullPath); // get asset path and class diff --git a/openpype/hosts/unreal/integration/Source/OpenPype/Private/OpenPypePublishInstanceFactory.cpp b/openpype/hosts/unreal/integration/Source/OpenPype/Private/OpenPypePublishInstanceFactory.cpp new file mode 100644 index 0000000000..e61964c689 --- /dev/null +++ b/openpype/hosts/unreal/integration/Source/OpenPype/Private/OpenPypePublishInstanceFactory.cpp @@ -0,0 +1,20 @@ +#include "OpenPypePublishInstanceFactory.h" +#include "OpenPypePublishInstance.h" + +UOpenPypePublishInstanceFactory::UOpenPypePublishInstanceFactory(const FObjectInitializer& ObjectInitializer) + : UFactory(ObjectInitializer) +{ + SupportedClass = UOpenPypePublishInstance::StaticClass(); + bCreateNew = false; + bEditorImport = true; +} + +UObject* UOpenPypePublishInstanceFactory::FactoryCreateNew(UClass* Class, UObject* InParent, FName Name, EObjectFlags Flags, UObject* Context, FFeedbackContext* Warn) +{ + UOpenPypePublishInstance* OpenPypePublishInstance = NewObject(InParent, Class, Name, Flags); + return OpenPypePublishInstance; +} + +bool UOpenPypePublishInstanceFactory::ShouldShowInNewMenu() const { + return false; +} diff --git a/openpype/hosts/unreal/integration/Source/OpenPype/Private/OpenPypePythonBridge.cpp b/openpype/hosts/unreal/integration/Source/OpenPype/Private/OpenPypePythonBridge.cpp new file mode 100644 index 0000000000..767f089374 --- /dev/null +++ b/openpype/hosts/unreal/integration/Source/OpenPype/Private/OpenPypePythonBridge.cpp @@ -0,0 +1,13 @@ +#include "OpenPypePythonBridge.h" + +UOpenPypePythonBridge* UOpenPypePythonBridge::Get() +{ + TArray OpenPypePythonBridgeClasses; + GetDerivedClasses(UAvalonPythonBridge::StaticClass(), OpenPypePythonBridgeClasses); + int32 NumClasses = OpenPypePythonBridgeClasses.Num(); + if (NumClasses > 0) + { + return Cast(AvalonPythonBridgeClasses[NumClasses - 1]->GetDefaultObject()); + } + return nullptr; +}; \ No newline at end of file diff --git a/openpype/hosts/unreal/integration/Source/OpenPype/Private/OpenPypeStyle.cpp b/openpype/hosts/unreal/integration/Source/OpenPype/Private/OpenPypeStyle.cpp new file mode 100644 index 0000000000..a51c2d6aa5 --- /dev/null +++ b/openpype/hosts/unreal/integration/Source/OpenPype/Private/OpenPypeStyle.cpp @@ -0,0 +1,70 @@ +#include "OpenPypeStyle.h" +#include "Framework/Application/SlateApplication.h" +#include "Styling/SlateStyle.h" +#include "Styling/SlateStyleRegistry.h" + + +TUniquePtr< FSlateStyleSet > FOpenPypeStyle::OpenPypeStyleInstance = nullptr; + +void FOpenPypeStyle::Initialize() +{ + if (!OpenPypeStyleInstance.IsValid()) + { + OpenPypeStyleInstance = Create(); + FSlateStyleRegistry::RegisterSlateStyle(*OpenPypeStyleInstance); + } +} + +void FOpenPypeStyle::Shutdown() +{ + if (OpenPypeStyleInstance.IsValid()) + { + FSlateStyleRegistry::UnRegisterSlateStyle(*OpenPypeStyleInstance); + OpenPypeStyleInstance.Reset(); + } +} + +FName FOpenPypeStyle::GetStyleSetName() +{ + static FName StyleSetName(TEXT("OpenPypeStyle")); + return StyleSetName; +} + +FName FOpenPypeStyle::GetContextName() +{ + static FName ContextName(TEXT("OpenPype")); + return ContextName; +} + +#define IMAGE_BRUSH(RelativePath, ...) FSlateImageBrush( Style->RootToContentDir( RelativePath, TEXT(".png") ), __VA_ARGS__ ) + +const FVector2D Icon40x40(40.0f, 40.0f); + +TUniquePtr< FSlateStyleSet > FOpenPypeStyle::Create() +{ + TUniquePtr< FSlateStyleSet > Style = MakeUnique(GetStyleSetName()); + Style->SetContentRoot(FPaths::ProjectPluginsDir() / TEXT("OpenPype/Resources")); + + return Style; +} + +void FOpenPypeStyle::SetIcon(const FString& StyleName, const FString& ResourcePath) +{ + FSlateStyleSet* Style = OpenPypeStyleInstance.Get(); + + FString Name(GetContextName().ToString()); + Name = Name + "." + StyleName; + Style->Set(*Name, new FSlateImageBrush(Style->RootToContentDir(ResourcePath, TEXT(".png")), Icon40x40)); + + + FSlateApplication::Get().GetRenderer()->ReloadTextureResources(); +} + +#undef IMAGE_BRUSH + +const ISlateStyle& FOpenPypeStyle::Get() +{ + check(OpenPypeStyleInstance); + return *OpenPypeStyleInstance; + return *OpenPypeStyleInstance; +} diff --git a/openpype/hosts/unreal/integration/Source/Avalon/Public/AssetContainer.h b/openpype/hosts/unreal/integration/Source/OpenPype/Public/AssetContainer.h similarity index 100% rename from openpype/hosts/unreal/integration/Source/Avalon/Public/AssetContainer.h rename to openpype/hosts/unreal/integration/Source/OpenPype/Public/AssetContainer.h diff --git a/openpype/hosts/unreal/integration/Source/Avalon/Public/AssetContainerFactory.h b/openpype/hosts/unreal/integration/Source/OpenPype/Public/AssetContainerFactory.h similarity index 89% rename from openpype/hosts/unreal/integration/Source/Avalon/Public/AssetContainerFactory.h rename to openpype/hosts/unreal/integration/Source/OpenPype/Public/AssetContainerFactory.h index 62b6e73640..331ce6bb50 100644 --- a/openpype/hosts/unreal/integration/Source/Avalon/Public/AssetContainerFactory.h +++ b/openpype/hosts/unreal/integration/Source/OpenPype/Public/AssetContainerFactory.h @@ -10,7 +10,7 @@ * */ UCLASS() -class AVALON_API UAssetContainerFactory : public UFactory +class OPENPYPE_API UAssetContainerFactory : public UFactory { GENERATED_BODY() diff --git a/openpype/hosts/unreal/integration/Source/Avalon/Public/Avalon.h b/openpype/hosts/unreal/integration/Source/OpenPype/Public/OpenPype.h similarity index 87% rename from openpype/hosts/unreal/integration/Source/Avalon/Public/Avalon.h rename to openpype/hosts/unreal/integration/Source/OpenPype/Public/OpenPype.h index 2dd6a825ab..db3f299354 100644 --- a/openpype/hosts/unreal/integration/Source/Avalon/Public/Avalon.h +++ b/openpype/hosts/unreal/integration/Source/OpenPype/Public/OpenPype.h @@ -5,7 +5,7 @@ #include "Engine.h" -class FAvalonModule : public IModuleInterface +class FOpenPypeModule : public IModuleInterface { public: virtual void StartupModule() override; diff --git a/openpype/hosts/unreal/integration/Source/Avalon/Public/AvalonLib.h b/openpype/hosts/unreal/integration/Source/OpenPype/Public/OpenPypeLib.h similarity index 88% rename from openpype/hosts/unreal/integration/Source/Avalon/Public/AvalonLib.h rename to openpype/hosts/unreal/integration/Source/OpenPype/Public/OpenPypeLib.h index da3369970c..3b4afe1408 100644 --- a/openpype/hosts/unreal/integration/Source/Avalon/Public/AvalonLib.h +++ b/openpype/hosts/unreal/integration/Source/OpenPype/Public/OpenPypeLib.h @@ -5,7 +5,7 @@ UCLASS(Blueprintable) -class AVALON_API UAvalonLib : public UObject +class OPENPYPE_API UOpenPypeLib : public UObject { GENERATED_BODY() diff --git a/openpype/hosts/unreal/integration/Source/Avalon/Public/AvalonPublishInstance.h b/openpype/hosts/unreal/integration/Source/OpenPype/Public/OpenPypePublishInstance.h similarity index 65% rename from openpype/hosts/unreal/integration/Source/Avalon/Public/AvalonPublishInstance.h rename to openpype/hosts/unreal/integration/Source/OpenPype/Public/OpenPypePublishInstance.h index 7678f78924..0a27a078d7 100644 --- a/openpype/hosts/unreal/integration/Source/Avalon/Public/AvalonPublishInstance.h +++ b/openpype/hosts/unreal/integration/Source/OpenPype/Public/OpenPypePublishInstance.h @@ -1,16 +1,16 @@ #pragma once #include "Engine.h" -#include "AvalonPublishInstance.generated.h" +#include "OpenPypePublishInstance.generated.h" UCLASS(Blueprintable) -class AVALON_API UAvalonPublishInstance : public UObject +class OPENPYPE_API UOpenPypePublishInstance : public UObject { GENERATED_BODY() public: - UAvalonPublishInstance(const FObjectInitializer& ObjectInitalizer); + UOpenPypePublishInstance(const FObjectInitializer& ObjectInitalizer); UPROPERTY(EditAnywhere, BlueprintReadOnly) TArray assets; diff --git a/openpype/hosts/unreal/integration/Source/Avalon/Public/AvalonPublishInstanceFactory.h b/openpype/hosts/unreal/integration/Source/OpenPype/Public/OpenPypePublishInstanceFactory.h similarity index 61% rename from openpype/hosts/unreal/integration/Source/Avalon/Public/AvalonPublishInstanceFactory.h rename to openpype/hosts/unreal/integration/Source/OpenPype/Public/OpenPypePublishInstanceFactory.h index 79e781c60c..a2b3abe13e 100644 --- a/openpype/hosts/unreal/integration/Source/Avalon/Public/AvalonPublishInstanceFactory.h +++ b/openpype/hosts/unreal/integration/Source/OpenPype/Public/OpenPypePublishInstanceFactory.h @@ -2,18 +2,18 @@ #include "CoreMinimal.h" #include "Factories/Factory.h" -#include "AvalonPublishInstanceFactory.generated.h" +#include "OpenPypePublishInstanceFactory.generated.h" /** * */ UCLASS() -class AVALON_API UAvalonPublishInstanceFactory : public UFactory +class OPENPYPE_API UOpenPypePublishInstanceFactory : public UFactory { GENERATED_BODY() public: - UAvalonPublishInstanceFactory(const FObjectInitializer& ObjectInitializer); + UOpenPypePublishInstanceFactory(const FObjectInitializer& ObjectInitializer); virtual UObject* FactoryCreateNew(UClass* Class, UObject* InParent, FName Name, EObjectFlags Flags, UObject* Context, FFeedbackContext* Warn) override; virtual bool ShouldShowInNewMenu() const override; }; \ No newline at end of file diff --git a/openpype/hosts/unreal/integration/Source/Avalon/Public/AvalonPythonBridge.h b/openpype/hosts/unreal/integration/Source/OpenPype/Public/OpenPypePythonBridge.h similarity index 71% rename from openpype/hosts/unreal/integration/Source/Avalon/Public/AvalonPythonBridge.h rename to openpype/hosts/unreal/integration/Source/OpenPype/Public/OpenPypePythonBridge.h index db4b16d53f..692aab2e5e 100644 --- a/openpype/hosts/unreal/integration/Source/Avalon/Public/AvalonPythonBridge.h +++ b/openpype/hosts/unreal/integration/Source/OpenPype/Public/OpenPypePythonBridge.h @@ -1,15 +1,15 @@ #pragma once #include "Engine.h" -#include "AvalonPythonBridge.generated.h" +#include "OpenPypePythonBridge.generated.h" UCLASS(Blueprintable) -class UAvalonPythonBridge : public UObject +class UOpenPypePythonBridge : public UObject { GENERATED_BODY() public: UFUNCTION(BlueprintCallable, Category = Python) - static UAvalonPythonBridge* Get(); + static UOpenPypePythonBridge* Get(); UFUNCTION(BlueprintImplementableEvent, Category = Python) void RunInPython_Popup() const; diff --git a/openpype/hosts/unreal/integration/Source/Avalon/Public/AvalonStyle.h b/openpype/hosts/unreal/integration/Source/OpenPype/Public/OpenPypeStyle.h similarity index 95% rename from openpype/hosts/unreal/integration/Source/Avalon/Public/AvalonStyle.h rename to openpype/hosts/unreal/integration/Source/OpenPype/Public/OpenPypeStyle.h index ffb2bc7aa4..0e9400406a 100644 --- a/openpype/hosts/unreal/integration/Source/Avalon/Public/AvalonStyle.h +++ b/openpype/hosts/unreal/integration/Source/OpenPype/Public/OpenPypeStyle.h @@ -5,7 +5,7 @@ class FSlateStyleSet; class ISlateStyle; -class FAvalonStyle +class FOpenPypeStyle { public: static void Initialize(); diff --git a/openpype/hosts/unreal/plugins/create/create_camera.py b/openpype/hosts/unreal/plugins/create/create_camera.py index eda2b52be3..c2905fb6dd 100644 --- a/openpype/hosts/unreal/plugins/create/create_camera.py +++ b/openpype/hosts/unreal/plugins/create/create_camera.py @@ -16,7 +16,7 @@ class CreateCamera(Creator): family = "camera" icon = "cubes" - root = "/Game/Avalon/Instances" + root = "/Game/OpenPype/Instances" suffix = "_INS" def __init__(self, *args, **kwargs): diff --git a/openpype/hosts/unreal/plugins/create/create_layout.py b/openpype/hosts/unreal/plugins/create/create_layout.py index 239b72787b..00e83cf433 100644 --- a/openpype/hosts/unreal/plugins/create/create_layout.py +++ b/openpype/hosts/unreal/plugins/create/create_layout.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- from unreal import EditorLevelLibrary as ell from openpype.hosts.unreal.api.plugin import Creator from avalon.unreal import ( @@ -6,7 +7,7 @@ from avalon.unreal import ( class CreateLayout(Creator): - """Layout output for character rigs""" + """Layout output for character rigs.""" name = "layoutMain" label = "Layout" diff --git a/openpype/hosts/unreal/plugins/create/create_look.py b/openpype/hosts/unreal/plugins/create/create_look.py index 7d3913b883..59c40d3e74 100644 --- a/openpype/hosts/unreal/plugins/create/create_look.py +++ b/openpype/hosts/unreal/plugins/create/create_look.py @@ -1,10 +1,12 @@ -import unreal +# -*- coding: utf-8 -*- +"""Create look in Unreal.""" +import unreal # noqa from openpype.hosts.unreal.api.plugin import Creator -from avalon.unreal import pipeline +from openpype.hosts.unreal.api import pipeline class CreateLook(Creator): - """Shader connections defining shape look""" + """Shader connections defining shape look.""" name = "unrealLook" label = "Unreal - Look" @@ -49,14 +51,14 @@ class CreateLook(Creator): for material in materials: name = material.get_editor_property('material_slot_name') object_path = f"{full_path}/{name}.{name}" - object = unreal.EditorAssetLibrary.duplicate_loaded_asset( + unreal_object = unreal.EditorAssetLibrary.duplicate_loaded_asset( cube.get_asset(), object_path ) # Remove the default material of the cube object - object.get_editor_property('static_materials').pop() + unreal_object.get_editor_property('static_materials').pop() - object.add_material( + unreal_object.add_material( material.get_editor_property('material_interface')) self.data["members"].append(object_path) diff --git a/openpype/hosts/unreal/plugins/create/create_staticmeshfbx.py b/openpype/hosts/unreal/plugins/create/create_staticmeshfbx.py index 4cc67e0f1f..700eac7366 100644 --- a/openpype/hosts/unreal/plugins/create/create_staticmeshfbx.py +++ b/openpype/hosts/unreal/plugins/create/create_staticmeshfbx.py @@ -1,12 +1,14 @@ -import unreal +# -*- coding: utf-8 -*- +"""Create Static Meshes as FBX geometry.""" +import unreal # noqa from openpype.hosts.unreal.api.plugin import Creator -from avalon.unreal import ( +from openpype.hosts.unreal.api.pipeline import ( instantiate, ) class CreateStaticMeshFBX(Creator): - """Static FBX geometry""" + """Static FBX geometry.""" name = "unrealStaticMeshMain" label = "Unreal - Static Mesh" diff --git a/openpype/hosts/unreal/plugins/load/load_alembic_geometrycache.py b/openpype/hosts/unreal/plugins/load/load_alembic_geometrycache.py index e2023e8b47..a0cd69326f 100644 --- a/openpype/hosts/unreal/plugins/load/load_alembic_geometrycache.py +++ b/openpype/hosts/unreal/plugins/load/load_alembic_geometrycache.py @@ -1,12 +1,15 @@ +# -*- coding: utf-8 -*- +"""Loader for published alembics.""" import os from avalon import api, pipeline -from avalon.unreal import lib -from avalon.unreal import pipeline as unreal_pipeline -import unreal +from openpype.hosts.unreal.api import lib, plugin +from openpype.hosts.unreal.api import pipeline as unreal_pipeline + +import unreal # noqa -class PointCacheAlembicLoader(api.Loader): +class PointCacheAlembicLoader(plugin.Loader): """Load Point Cache from Alembic""" families = ["model", "pointcache"] @@ -56,8 +59,7 @@ class PointCacheAlembicLoader(api.Loader): return task def load(self, context, name, namespace, data): - """ - Load and containerise representation into Content Browser. + """Load and containerise representation into Content Browser. This is two step process. First, import FBX to temporary path and then call `containerise()` on it - this moves all content to new @@ -76,10 +78,10 @@ class PointCacheAlembicLoader(api.Loader): Returns: list(str): list of container content - """ - # Create directory for asset and avalon container - root = "/Game/Avalon/Assets" + """ + # Create directory for asset and OpenPype container + root = "/Game/OpenPype/Assets" asset = context.get('asset').get('name') suffix = "_CON" if asset: @@ -109,7 +111,7 @@ class PointCacheAlembicLoader(api.Loader): unreal.AssetToolsHelpers.get_asset_tools().import_asset_tasks([task]) # noqa: E501 # Create Asset Container - lib.create_avalon_container( + unreal_pipeline.create_container( container=container_name, path=asset_dir) data = { diff --git a/openpype/hosts/unreal/plugins/load/load_alembic_skeletalmesh.py b/openpype/hosts/unreal/plugins/load/load_alembic_skeletalmesh.py index b652af0b89..0236bab138 100644 --- a/openpype/hosts/unreal/plugins/load/load_alembic_skeletalmesh.py +++ b/openpype/hosts/unreal/plugins/load/load_alembic_skeletalmesh.py @@ -1,12 +1,14 @@ +# -*- coding: utf-8 -*- +"""Load Skeletal Mesh alembics.""" import os from avalon import api, pipeline -from avalon.unreal import lib -from avalon.unreal import pipeline as unreal_pipeline -import unreal +from openpype.hosts.unreal.api import plugin +from openpype.hosts.unreal.api import pipeline as unreal_pipeline +import unreal # noqa -class SkeletalMeshAlembicLoader(api.Loader): +class SkeletalMeshAlembicLoader(plugin.Loader): """Load Unreal SkeletalMesh from Alembic""" families = ["pointcache"] @@ -16,8 +18,7 @@ class SkeletalMeshAlembicLoader(api.Loader): color = "orange" def load(self, context, name, namespace, data): - """ - Load and containerise representation into Content Browser. + """Load and containerise representation into Content Browser. This is two step process. First, import FBX to temporary path and then call `containerise()` on it - this moves all content to new @@ -38,8 +39,8 @@ class SkeletalMeshAlembicLoader(api.Loader): list(str): list of container content """ - # Create directory for asset and avalon container - root = "/Game/Avalon/Assets" + # Create directory for asset and openpype container + root = "/Game/OpenPype/Assets" asset = context.get('asset').get('name') suffix = "_CON" if asset: @@ -74,7 +75,7 @@ class SkeletalMeshAlembicLoader(api.Loader): unreal.AssetToolsHelpers.get_asset_tools().import_asset_tasks([task]) # noqa: E501 # Create Asset Container - lib.create_avalon_container( + unreal_pipeline.create_container( container=container_name, path=asset_dir) data = { diff --git a/openpype/hosts/unreal/plugins/load/load_alembic_staticmesh.py b/openpype/hosts/unreal/plugins/load/load_alembic_staticmesh.py index ccec31b832..aec8b45041 100644 --- a/openpype/hosts/unreal/plugins/load/load_alembic_staticmesh.py +++ b/openpype/hosts/unreal/plugins/load/load_alembic_staticmesh.py @@ -1,12 +1,14 @@ +# -*- coding: utf-8 -*- +"""Loader for Static Mesh alembics.""" import os from avalon import api, pipeline -from avalon.unreal import lib -from avalon.unreal import pipeline as unreal_pipeline -import unreal +from openpype.hosts.unreal.api import lib, plugin +from openpype.hosts.unreal.api import pipeline as unreal_pipeline +import unreal # noqa -class StaticMeshAlembicLoader(api.Loader): +class StaticMeshAlembicLoader(plugin.Loader): """Load Unreal StaticMesh from Alembic""" families = ["model"] @@ -49,8 +51,7 @@ class StaticMeshAlembicLoader(api.Loader): return task def load(self, context, name, namespace, data): - """ - Load and containerise representation into Content Browser. + """Load and containerise representation into Content Browser. This is two step process. First, import FBX to temporary path and then call `containerise()` on it - this moves all content to new @@ -69,10 +70,10 @@ class StaticMeshAlembicLoader(api.Loader): Returns: list(str): list of container content - """ - # Create directory for asset and avalon container - root = "/Game/Avalon/Assets" + """ + # Create directory for asset and OpenPype container + root = "/Game/OpenPype/Assets" asset = context.get('asset').get('name') suffix = "_CON" if asset: @@ -93,7 +94,7 @@ class StaticMeshAlembicLoader(api.Loader): unreal.AssetToolsHelpers.get_asset_tools().import_asset_tasks([task]) # noqa: E501 # Create Asset Container - lib.create_avalon_container( + unreal_pipeline.create_container( container=container_name, path=asset_dir) data = { diff --git a/openpype/hosts/unreal/plugins/load/load_animation.py b/openpype/hosts/unreal/plugins/load/load_animation.py index 20baa30847..63c734b969 100644 --- a/openpype/hosts/unreal/plugins/load/load_animation.py +++ b/openpype/hosts/unreal/plugins/load/load_animation.py @@ -1,14 +1,16 @@ +# -*- coding: utf-8 -*- +"""Load FBX with animations.""" import os import json from avalon import api, pipeline -from avalon.unreal import lib -from avalon.unreal import pipeline as unreal_pipeline -import unreal +from openpype.hosts.unreal.api import plugin +from openpype.hosts.unreal.api import pipeline as unreal_pipeline +import unreal # noqa -class AnimationFBXLoader(api.Loader): - """Load Unreal SkeletalMesh from FBX""" +class AnimationFBXLoader(plugin.Loader): + """Load Unreal SkeletalMesh from FBX.""" families = ["animation"] label = "Import FBX Animation" @@ -37,10 +39,10 @@ class AnimationFBXLoader(api.Loader): Returns: list(str): list of container content - """ - # Create directory for asset and avalon container - root = "/Game/Avalon/Assets" + """ + # Create directory for asset and OpenPype container + root = "/Game/OpenPype/Assets" asset = context.get('asset').get('name') suffix = "_CON" if asset: @@ -62,9 +64,9 @@ class AnimationFBXLoader(api.Loader): task = unreal.AssetImportTask() task.options = unreal.FbxImportUI() - libpath = self.fname.replace("fbx", "json") + lib_path = self.fname.replace("fbx", "json") - with open(libpath, "r") as fp: + with open(lib_path, "r") as fp: data = json.load(fp) instance_name = data.get("instance_name") @@ -127,7 +129,7 @@ class AnimationFBXLoader(api.Loader): unreal.AssetToolsHelpers.get_asset_tools().import_asset_tasks([task]) # Create Asset Container - lib.create_avalon_container( + unreal_pipeline.create_container( container=container_name, path=asset_dir) data = { diff --git a/openpype/hosts/unreal/plugins/load/load_camera.py b/openpype/hosts/unreal/plugins/load/load_camera.py index b2b25eec73..c6bcfa08a9 100644 --- a/openpype/hosts/unreal/plugins/load/load_camera.py +++ b/openpype/hosts/unreal/plugins/load/load_camera.py @@ -1,12 +1,14 @@ +# -*- coding: utf-8 -*- +"""Load camera from FBX.""" import os from avalon import api, io, pipeline -from avalon.unreal import lib -from avalon.unreal import pipeline as unreal_pipeline -import unreal +from openpype.hosts.unreal.api import lib, plugin +from openpype.hosts.unreal.api import pipeline as unreal_pipeline +import unreal # noqa -class CameraLoader(api.Loader): +class CameraLoader(plugin.Loader): """Load Unreal StaticMesh from FBX""" families = ["camera"] @@ -38,8 +40,8 @@ class CameraLoader(api.Loader): list(str): list of container content """ - # Create directory for asset and avalon container - root = "/Game/Avalon/Assets" + # Create directory for asset and OpenPype container + root = "/Game/OpenPype/Assets" asset = context.get('asset').get('name') suffix = "_CON" if asset: @@ -109,7 +111,7 @@ class CameraLoader(api.Loader): ) # Create Asset Container - lib.create_avalon_container(container=container_name, path=asset_dir) + unreal_pipeline.create_container(container=container_name, path=asset_dir) data = { "schema": "openpype:container-2.0", diff --git a/openpype/hosts/unreal/plugins/load/load_layout.py b/openpype/hosts/unreal/plugins/load/load_layout.py index 19d0b74e3e..a5e93a009f 100644 --- a/openpype/hosts/unreal/plugins/load/load_layout.py +++ b/openpype/hosts/unreal/plugins/load/load_layout.py @@ -1,3 +1,5 @@ +# -*- coding: utf-8 -*- +"""Loader for layouts.""" import os import json from pathlib import Path @@ -10,11 +12,11 @@ from unreal import FBXImportType from unreal import MathLibrary as umath from avalon import api, pipeline -from avalon.unreal import lib -from avalon.unreal import pipeline as unreal_pipeline +from openpype.hosts.unreal.api import lib, plugin +from openpype.hosts.unreal.api import pipeline as unreal_pipeline -class LayoutLoader(api.Loader): +class LayoutLoader(plugin.Loader): """Load Layout from a JSON file""" families = ["layout"] @@ -23,6 +25,7 @@ class LayoutLoader(api.Loader): label = "Load Layout" icon = "code-fork" color = "orange" + ASSET_ROOT = "/Game/OpenPype/Assets" def _get_asset_containers(self, path): ar = unreal.AssetRegistryHelpers.get_asset_registry() @@ -40,7 +43,8 @@ class LayoutLoader(api.Loader): return asset_containers - def _get_fbx_loader(self, loaders, family): + @staticmethod + def _get_fbx_loader(loaders, family): name = "" if family == 'rig': name = "SkeletalMeshFBXLoader" @@ -58,7 +62,8 @@ class LayoutLoader(api.Loader): return None - def _get_abc_loader(self, loaders, family): + @staticmethod + def _get_abc_loader(loaders, family): name = "" if family == 'rig': name = "SkeletalMeshAlembicLoader" @@ -74,14 +79,15 @@ class LayoutLoader(api.Loader): return None - def _process_family(self, assets, classname, transform, inst_name=None): + @staticmethod + def _process_family(assets, class_name, transform, inst_name=None): ar = unreal.AssetRegistryHelpers.get_asset_registry() actors = [] for asset in assets: obj = ar.get_asset_by_object_path(asset).get_asset() - if obj.get_class().get_name() == classname: + if obj.get_class().get_name() == class_name: actor = EditorLevelLibrary.spawn_actor_from_object( obj, transform.get('translation') @@ -111,8 +117,9 @@ class LayoutLoader(api.Loader): return actors + @staticmethod def _import_animation( - self, asset_dir, path, instance_name, skeleton, actors_dict, + asset_dir, path, instance_name, skeleton, actors_dict, animation_file): anim_file = Path(animation_file) anim_file_name = anim_file.with_suffix('') @@ -192,10 +199,10 @@ class LayoutLoader(api.Loader): actor.skeletal_mesh_component.animation_data.set_editor_property( 'anim_to_play', animation) - def _process(self, libpath, asset_dir, loaded=None): + def _process(self, lib_path, asset_dir, loaded=None): ar = unreal.AssetRegistryHelpers.get_asset_registry() - with open(libpath, "r") as fp: + with open(lib_path, "r") as fp: data = json.load(fp) all_loaders = api.discover(api.Loader) @@ -203,7 +210,7 @@ class LayoutLoader(api.Loader): if not loaded: loaded = [] - path = Path(libpath) + path = Path(lib_path) skeleton_dict = {} actors_dict = {} @@ -292,17 +299,18 @@ class LayoutLoader(api.Loader): asset_dir, path, instance_name, skeleton, actors_dict, animation_file) - def _remove_family(self, assets, components, classname, propname): + @staticmethod + def _remove_family(assets, components, class_name, prop_name): ar = unreal.AssetRegistryHelpers.get_asset_registry() objects = [] for a in assets: obj = ar.get_asset_by_object_path(a) - if obj.get_asset().get_class().get_name() == classname: + if obj.get_asset().get_class().get_name() == class_name: objects.append(obj) for obj in objects: for comp in components: - if comp.get_editor_property(propname) == obj.get_asset(): + if comp.get_editor_property(prop_name) == obj.get_asset(): comp.get_owner().destroy_actor() def _remove_actors(self, path): @@ -334,8 +342,7 @@ class LayoutLoader(api.Loader): assets, skel_meshes_comp, 'SkeletalMesh', 'skeletal_mesh') def load(self, context, name, namespace, options): - """ - Load and containerise representation into Content Browser. + """Load and containerise representation into Content Browser. This is two step process. First, import FBX to temporary path and then call `containerise()` on it - this moves all content to new @@ -349,14 +356,14 @@ class LayoutLoader(api.Loader): This is not passed here, so namespace is set by `containerise()` because only then we know real path. - data (dict): Those would be data to be imprinted. This is not used + options (dict): Those would be data to be imprinted. This is not used now, data are imprinted by `containerise()`. Returns: list(str): list of container content """ # Create directory for asset and avalon container - root = "/Game/Avalon/Assets" + root = self.ASSET_ROOT asset = context.get('asset').get('name') suffix = "_CON" if asset: @@ -375,7 +382,7 @@ class LayoutLoader(api.Loader): self._process(self.fname, asset_dir) # Create Asset Container - lib.create_avalon_container( + unreal_pipeline.create_container( container=container_name, path=asset_dir) data = { @@ -406,7 +413,7 @@ class LayoutLoader(api.Loader): source_path = api.get_representation_path(representation) destination_path = container["namespace"] - libpath = Path(api.get_representation_path(representation)) + lib_path = Path(api.get_representation_path(representation)) self._remove_actors(destination_path) @@ -502,7 +509,7 @@ class LayoutLoader(api.Loader): if animation_file and skeleton: self._import_animation( - destination_path, libpath, + destination_path, lib_path, instance_name, skeleton, actors_dict, animation_file) diff --git a/openpype/hosts/unreal/plugins/load/load_rig.py b/openpype/hosts/unreal/plugins/load/load_rig.py index c7d095aa21..1503477ec7 100644 --- a/openpype/hosts/unreal/plugins/load/load_rig.py +++ b/openpype/hosts/unreal/plugins/load/load_rig.py @@ -1,13 +1,15 @@ +# -*- coding: utf-8 -*- +"""Load Skeletal Meshes form FBX.""" import os from avalon import api, pipeline -from avalon.unreal import lib -from avalon.unreal import pipeline as unreal_pipeline -import unreal +from openpype.hosts.unreal.api import lib, plugin +from openpype.hosts.unreal.api import pipeline as unreal_pipeline +import unreal # noqa -class SkeletalMeshFBXLoader(api.Loader): - """Load Unreal SkeletalMesh from FBX""" +class SkeletalMeshFBXLoader(plugin.Loader): + """Load Unreal SkeletalMesh from FBX.""" families = ["rig"] label = "Import FBX Skeletal Mesh" @@ -16,8 +18,7 @@ class SkeletalMeshFBXLoader(api.Loader): color = "orange" def load(self, context, name, namespace, options): - """ - Load and containerise representation into Content Browser. + """Load and containerise representation into Content Browser. This is two step process. First, import FBX to temporary path and then call `containerise()` on it - this moves all content to new @@ -31,15 +32,15 @@ class SkeletalMeshFBXLoader(api.Loader): This is not passed here, so namespace is set by `containerise()` because only then we know real path. - data (dict): Those would be data to be imprinted. This is not used + options (dict): Those would be data to be imprinted. This is not used now, data are imprinted by `containerise()`. Returns: list(str): list of container content - """ - # Create directory for asset and avalon container - root = "/Game/Avalon/Assets" + """ + # Create directory for asset and OpenPype container + root = "/Game/OpenPype/Assets" if options and options.get("asset_dir"): root = options["asset_dir"] asset = context.get('asset').get('name') @@ -94,7 +95,7 @@ class SkeletalMeshFBXLoader(api.Loader): unreal.AssetToolsHelpers.get_asset_tools().import_asset_tasks([task]) # noqa: E501 # Create Asset Container - lib.create_avalon_container( + unreal_pipeline.create_container( container=container_name, path=asset_dir) data = { diff --git a/openpype/hosts/unreal/plugins/load/load_staticmeshfbx.py b/openpype/hosts/unreal/plugins/load/load_staticmeshfbx.py index 510c4331ad..14ca39c728 100644 --- a/openpype/hosts/unreal/plugins/load/load_staticmeshfbx.py +++ b/openpype/hosts/unreal/plugins/load/load_staticmeshfbx.py @@ -1,13 +1,15 @@ +# -*- coding: utf-8 -*- +"""Load Static meshes form FBX.""" import os from avalon import api, pipeline -from avalon.unreal import lib -from avalon.unreal import pipeline as unreal_pipeline -import unreal +from openpype.hosts.unreal.api import lib, plugin +from openpype.hosts.unreal.api import pipeline as unreal_pipeline +import unreal # noqa -class StaticMeshFBXLoader(api.Loader): - """Load Unreal StaticMesh from FBX""" +class StaticMeshFBXLoader(plugin.Loader): + """Load Unreal StaticMesh from FBX.""" families = ["model", "unrealStaticMesh"] label = "Import FBX Static Mesh" @@ -15,7 +17,8 @@ class StaticMeshFBXLoader(api.Loader): icon = "cube" color = "orange" - def get_task(self, filename, asset_dir, asset_name, replace): + @staticmethod + def get_task(filename, asset_dir, asset_name, replace): task = unreal.AssetImportTask() options = unreal.FbxImportUI() import_data = unreal.FbxStaticMeshImportData() @@ -41,8 +44,7 @@ class StaticMeshFBXLoader(api.Loader): return task def load(self, context, name, namespace, options): - """ - Load and containerise representation into Content Browser. + """Load and containerise representation into Content Browser. This is two step process. First, import FBX to temporary path and then call `containerise()` on it - this moves all content to new @@ -56,15 +58,15 @@ class StaticMeshFBXLoader(api.Loader): This is not passed here, so namespace is set by `containerise()` because only then we know real path. - data (dict): Those would be data to be imprinted. This is not used + options (dict): Those would be data to be imprinted. This is not used now, data are imprinted by `containerise()`. Returns: list(str): list of container content """ - # Create directory for asset and avalon container - root = "/Game/Avalon/Assets" + # Create directory for asset and OpenPype container + root = "/Game/OpenPype/Assets" if options and options.get("asset_dir"): root = options["asset_dir"] asset = context.get('asset').get('name') @@ -87,7 +89,7 @@ class StaticMeshFBXLoader(api.Loader): unreal.AssetToolsHelpers.get_asset_tools().import_asset_tasks([task]) # noqa: E501 # Create Asset Container - lib.create_avalon_container( + unreal_pipeline.create_container( container=container_name, path=asset_dir) data = { diff --git a/openpype/hosts/unreal/plugins/publish/collect_current_file.py b/openpype/hosts/unreal/plugins/publish/collect_current_file.py index 4e828933bb..acd4c5c8d2 100644 --- a/openpype/hosts/unreal/plugins/publish/collect_current_file.py +++ b/openpype/hosts/unreal/plugins/publish/collect_current_file.py @@ -1,17 +1,18 @@ -import unreal - +# -*- coding: utf-8 -*- +"""Collect current project path.""" +import unreal # noqa import pyblish.api class CollectUnrealCurrentFile(pyblish.api.ContextPlugin): - """Inject the current working file into context""" + """Inject the current working file into context.""" order = pyblish.api.CollectorOrder - 0.5 label = "Unreal Current File" hosts = ['unreal'] def process(self, context): - """Inject the current working file""" + """Inject the current working file.""" current_file = unreal.Paths.get_project_file_path() context.data['currentFile'] = current_file diff --git a/openpype/hosts/unreal/plugins/publish/collect_instances.py b/openpype/hosts/unreal/plugins/publish/collect_instances.py index 62676f9938..94e732d728 100644 --- a/openpype/hosts/unreal/plugins/publish/collect_instances.py +++ b/openpype/hosts/unreal/plugins/publish/collect_instances.py @@ -1,12 +1,14 @@ +# -*- coding: utf-8 -*- +"""Collect publishable instances in Unreal.""" import ast -import unreal +import unreal # noqa import pyblish.api class CollectInstances(pyblish.api.ContextPlugin): - """Gather instances by AvalonPublishInstance class + """Gather instances by OpenPypePublishInstance class - This collector finds all paths containing `AvalonPublishInstance` class + This collector finds all paths containing `OpenPypePublishInstance` class asset Identifier: @@ -22,7 +24,7 @@ class CollectInstances(pyblish.api.ContextPlugin): ar = unreal.AssetRegistryHelpers.get_asset_registry() instance_containers = ar.get_assets_by_class( - "AvalonPublishInstance", True) + "OpenPypePublishInstance", True) for container_data in instance_containers: asset = container_data.get_asset() diff --git a/openpype/hosts/unreal/plugins/publish/extract_camera.py b/openpype/hosts/unreal/plugins/publish/extract_camera.py index 10862fc0ef..ce53824563 100644 --- a/openpype/hosts/unreal/plugins/publish/extract_camera.py +++ b/openpype/hosts/unreal/plugins/publish/extract_camera.py @@ -1,3 +1,5 @@ +# -*- coding: utf-8 -*- +"""Extract camera from Unreal.""" import os import unreal @@ -17,7 +19,7 @@ class ExtractCamera(openpype.api.Extractor): def process(self, instance): # Define extract output file path - stagingdir = self.staging_dir(instance) + staging_dir = self.staging_dir(instance) fbx_filename = "{}.fbx".format(instance.name) # Perform extraction @@ -38,7 +40,7 @@ class ExtractCamera(openpype.api.Extractor): sequence, sequence.get_bindings(), unreal.FbxExportOption(), - os.path.join(stagingdir, fbx_filename) + os.path.join(staging_dir, fbx_filename) ) break @@ -49,6 +51,6 @@ class ExtractCamera(openpype.api.Extractor): 'name': 'fbx', 'ext': 'fbx', 'files': fbx_filename, - "stagingDir": stagingdir, + "stagingDir": staging_dir, } instance.data["representations"].append(fbx_representation) diff --git a/openpype/hosts/unreal/plugins/publish/extract_layout.py b/openpype/hosts/unreal/plugins/publish/extract_layout.py index a47187cf47..2d09b0e7bd 100644 --- a/openpype/hosts/unreal/plugins/publish/extract_layout.py +++ b/openpype/hosts/unreal/plugins/publish/extract_layout.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import os import json import math @@ -20,7 +21,7 @@ class ExtractLayout(openpype.api.Extractor): def process(self, instance): # Define extract output file path - stagingdir = self.staging_dir(instance) + staging_dir = self.staging_dir(instance) # Perform extraction self.log.info("Performing extraction..") @@ -96,7 +97,7 @@ class ExtractLayout(openpype.api.Extractor): json_data.append(json_element) json_filename = "{}.json".format(instance.name) - json_path = os.path.join(stagingdir, json_filename) + json_path = os.path.join(staging_dir, json_filename) with open(json_path, "w+") as file: json.dump(json_data, fp=file, indent=2) @@ -108,6 +109,6 @@ class ExtractLayout(openpype.api.Extractor): 'name': 'json', 'ext': 'json', 'files': json_filename, - "stagingDir": stagingdir, + "stagingDir": staging_dir, } instance.data["representations"].append(json_representation) diff --git a/openpype/hosts/unreal/plugins/publish/extract_look.py b/openpype/hosts/unreal/plugins/publish/extract_look.py index 0f1539a7d5..ea39949417 100644 --- a/openpype/hosts/unreal/plugins/publish/extract_look.py +++ b/openpype/hosts/unreal/plugins/publish/extract_look.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import json import os @@ -17,7 +18,7 @@ class ExtractLook(openpype.api.Extractor): def process(self, instance): # Define extract output file path - stagingdir = self.staging_dir(instance) + staging_dir = self.staging_dir(instance) resources_dir = instance.data["resourcesDir"] ar = unreal.AssetRegistryHelpers.get_asset_registry() @@ -57,7 +58,7 @@ class ExtractLook(openpype.api.Extractor): tga_export_task.set_editor_property('automated', True) tga_export_task.set_editor_property('object', texture) tga_export_task.set_editor_property( - 'filename', f"{stagingdir}/{tga_filename}") + 'filename', f"{staging_dir}/{tga_filename}") tga_export_task.set_editor_property('prompt', False) tga_export_task.set_editor_property('selected', False) @@ -66,7 +67,7 @@ class ExtractLook(openpype.api.Extractor): json_element['tga_filename'] = tga_filename transfers.append(( - f"{stagingdir}/{tga_filename}", + f"{staging_dir}/{tga_filename}", f"{resources_dir}/{tga_filename}")) fbx_filename = f"{instance.name}_{name}.fbx" @@ -84,7 +85,7 @@ class ExtractLook(openpype.api.Extractor): task.set_editor_property('automated', True) task.set_editor_property('object', object) task.set_editor_property( - 'filename', f"{stagingdir}/{fbx_filename}") + 'filename', f"{staging_dir}/{fbx_filename}") task.set_editor_property('prompt', False) task.set_editor_property('selected', False) @@ -93,13 +94,13 @@ class ExtractLook(openpype.api.Extractor): json_element['fbx_filename'] = fbx_filename transfers.append(( - f"{stagingdir}/{fbx_filename}", + f"{staging_dir}/{fbx_filename}", f"{resources_dir}/{fbx_filename}")) json_data.append(json_element) json_filename = f"{instance.name}.json" - json_path = os.path.join(stagingdir, json_filename) + json_path = os.path.join(staging_dir, json_filename) with open(json_path, "w+") as file: json.dump(json_data, fp=file, indent=2) @@ -113,7 +114,7 @@ class ExtractLook(openpype.api.Extractor): 'name': 'json', 'ext': 'json', 'files': json_filename, - "stagingDir": stagingdir, + "stagingDir": staging_dir, } instance.data["representations"].append(json_representation)