mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-01 08:24:53 +01:00
Merge pull request #4199 from pypeclub/bugfix/support-for-unreal-5.1
This commit is contained in:
commit
7c0dcad801
9 changed files with 33 additions and 17 deletions
|
|
@ -2,6 +2,7 @@
|
||||||
import os
|
import os
|
||||||
import logging
|
import logging
|
||||||
from typing import List
|
from typing import List
|
||||||
|
import semver
|
||||||
|
|
||||||
import pyblish.api
|
import pyblish.api
|
||||||
|
|
||||||
|
|
@ -21,6 +22,9 @@ import unreal # noqa
|
||||||
|
|
||||||
logger = logging.getLogger("openpype.hosts.unreal")
|
logger = logging.getLogger("openpype.hosts.unreal")
|
||||||
OPENPYPE_CONTAINERS = "OpenPypeContainers"
|
OPENPYPE_CONTAINERS = "OpenPypeContainers"
|
||||||
|
UNREAL_VERSION = semver.VersionInfo(
|
||||||
|
*os.getenv("OPENPYPE_UNREAL_VERSION").split(".")
|
||||||
|
)
|
||||||
|
|
||||||
HOST_DIR = os.path.dirname(os.path.abspath(openpype.hosts.unreal.__file__))
|
HOST_DIR = os.path.dirname(os.path.abspath(openpype.hosts.unreal.__file__))
|
||||||
PLUGINS_DIR = os.path.join(HOST_DIR, "plugins")
|
PLUGINS_DIR = os.path.join(HOST_DIR, "plugins")
|
||||||
|
|
@ -111,7 +115,9 @@ def ls():
|
||||||
|
|
||||||
"""
|
"""
|
||||||
ar = unreal.AssetRegistryHelpers.get_asset_registry()
|
ar = unreal.AssetRegistryHelpers.get_asset_registry()
|
||||||
openpype_containers = ar.get_assets_by_class("AssetContainer", True)
|
# UE 5.1 changed how class name is specified
|
||||||
|
class_name = ["/Script/OpenPype", "AssetContainer"] if UNREAL_VERSION.major == 5 and UNREAL_VERSION.minor > 0 else "AssetContainer" # noqa
|
||||||
|
openpype_containers = ar.get_assets_by_class(class_name, True)
|
||||||
|
|
||||||
# get_asset_by_class returns AssetData. To get all metadata we need to
|
# get_asset_by_class returns AssetData. To get all metadata we need to
|
||||||
# load asset. get_tag_values() work only on metadata registered in
|
# load asset. get_tag_values() work only on metadata registered in
|
||||||
|
|
|
||||||
|
|
@ -150,6 +150,7 @@ class UnrealPrelaunchHook(PreLaunchHook):
|
||||||
engine_path=Path(engine_path)
|
engine_path=Path(engine_path)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
self.launch_context.env["OPENPYPE_UNREAL_VERSION"] = engine_version
|
||||||
# Append project file to launch arguments
|
# Append project file to launch arguments
|
||||||
self.launch_context.launch_args.append(
|
self.launch_context.launch_args.append(
|
||||||
f"\"{project_file.as_posix()}\"")
|
f"\"{project_file.as_posix()}\"")
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,11 @@ public class OpenPype : ModuleRules
|
||||||
{
|
{
|
||||||
public OpenPype(ReadOnlyTargetRules Target) : base(Target)
|
public OpenPype(ReadOnlyTargetRules Target) : base(Target)
|
||||||
{
|
{
|
||||||
|
DefaultBuildSettings = BuildSettingsVersion.V2;
|
||||||
|
bLegacyPublicIncludePaths = false;
|
||||||
|
ShadowVariableWarningLevel = WarningLevel.Error;
|
||||||
PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs;
|
PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs;
|
||||||
|
IncludeOrderVersion = EngineIncludeOrderVersion.Unreal5_0;
|
||||||
|
|
||||||
PublicIncludePaths.AddRange(
|
PublicIncludePaths.AddRange(
|
||||||
new string[] {
|
new string[] {
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
// Fill out your copyright notice in the Description page of Project Settings.
|
// Fill out your copyright notice in the Description page of Project Settings.
|
||||||
|
|
||||||
#include "AssetContainer.h"
|
#include "AssetContainer.h"
|
||||||
#include "AssetRegistryModule.h"
|
#include "AssetRegistry/AssetRegistryModule.h"
|
||||||
#include "Misc/PackageName.h"
|
#include "Misc/PackageName.h"
|
||||||
#include "Engine.h"
|
#include "Engine.h"
|
||||||
#include "Containers/UnrealString.h"
|
#include "Containers/UnrealString.h"
|
||||||
|
|
@ -30,8 +30,8 @@ void UAssetContainer::OnAssetAdded(const FAssetData& AssetData)
|
||||||
|
|
||||||
// get asset path and class
|
// get asset path and class
|
||||||
FString assetPath = AssetData.GetFullName();
|
FString assetPath = AssetData.GetFullName();
|
||||||
FString assetFName = AssetData.AssetClass.ToString();
|
FString assetFName = AssetData.AssetClassPath.ToString();
|
||||||
|
UE_LOG(LogTemp, Log, TEXT("asset name %s"), *assetFName);
|
||||||
// split path
|
// split path
|
||||||
assetPath.ParseIntoArray(split, TEXT(" "), true);
|
assetPath.ParseIntoArray(split, TEXT(" "), true);
|
||||||
|
|
||||||
|
|
@ -60,7 +60,7 @@ void UAssetContainer::OnAssetRemoved(const FAssetData& AssetData)
|
||||||
|
|
||||||
// get asset path and class
|
// get asset path and class
|
||||||
FString assetPath = AssetData.GetFullName();
|
FString assetPath = AssetData.GetFullName();
|
||||||
FString assetFName = AssetData.AssetClass.ToString();
|
FString assetFName = AssetData.AssetClassPath.ToString();
|
||||||
|
|
||||||
// split path
|
// split path
|
||||||
assetPath.ParseIntoArray(split, TEXT(" "), true);
|
assetPath.ParseIntoArray(split, TEXT(" "), true);
|
||||||
|
|
@ -93,7 +93,7 @@ void UAssetContainer::OnAssetRenamed(const FAssetData& AssetData, const FString&
|
||||||
|
|
||||||
// get asset path and class
|
// get asset path and class
|
||||||
FString assetPath = AssetData.GetFullName();
|
FString assetPath = AssetData.GetFullName();
|
||||||
FString assetFName = AssetData.AssetClass.ToString();
|
FString assetFName = AssetData.AssetClassPath.ToString();
|
||||||
|
|
||||||
// split path
|
// split path
|
||||||
assetPath.ParseIntoArray(split, TEXT(" "), true);
|
assetPath.ParseIntoArray(split, TEXT(" "), true);
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "OpenPypePublishInstance.h"
|
#include "OpenPypePublishInstance.h"
|
||||||
#include "AssetRegistryModule.h"
|
#include "AssetRegistry/AssetRegistryModule.h"
|
||||||
#include "AssetToolsModule.h"
|
#include "AssetToolsModule.h"
|
||||||
#include "Framework/Notifications/NotificationManager.h"
|
#include "Framework/Notifications/NotificationManager.h"
|
||||||
#include "SNotificationList.h"
|
#include "Widgets/Notifications/SNotificationList.h"
|
||||||
|
|
||||||
//Moves all the invalid pointers to the end to prepare them for the shrinking
|
//Moves all the invalid pointers to the end to prepare them for the shrinking
|
||||||
#define REMOVE_INVALID_ENTRIES(VAR) VAR.CompactStable(); \
|
#define REMOVE_INVALID_ENTRIES(VAR) VAR.CompactStable(); \
|
||||||
|
|
@ -47,7 +47,7 @@ void UOpenPypePublishInstance::OnAssetCreated(const FAssetData& InAssetData)
|
||||||
if (!IsValid(Asset))
|
if (!IsValid(Asset))
|
||||||
{
|
{
|
||||||
UE_LOG(LogAssetData, Warning, TEXT("Asset \"%s\" is not valid! Skipping the addition."),
|
UE_LOG(LogAssetData, Warning, TEXT("Asset \"%s\" is not valid! Skipping the addition."),
|
||||||
*InAssetData.ObjectPath.ToString());
|
*InAssetData.GetObjectPathString());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
#include "CoreMinimal.h"
|
#include "CoreMinimal.h"
|
||||||
#include "UObject/NoExportTypes.h"
|
#include "UObject/NoExportTypes.h"
|
||||||
#include "Engine/AssetUserData.h"
|
#include "Engine/AssetUserData.h"
|
||||||
#include "AssetData.h"
|
#include "AssetRegistry/AssetData.h"
|
||||||
#include "AssetContainer.generated.h"
|
#include "AssetContainer.generated.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "EditorTutorial.h"
|
|
||||||
#include "Engine.h"
|
#include "Engine.h"
|
||||||
#include "OpenPypePublishInstance.generated.h"
|
#include "OpenPypePublishInstance.generated.h"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,10 @@ def get_engine_versions(env=None):
|
||||||
# environment variable not set
|
# environment variable not set
|
||||||
pass
|
pass
|
||||||
except OSError:
|
except OSError:
|
||||||
# specified directory doesn't exists
|
# specified directory doesn't exist
|
||||||
|
pass
|
||||||
|
except StopIteration:
|
||||||
|
# specified directory doesn't exist
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# if we've got something, terminate auto-detection process
|
# if we've got something, terminate auto-detection process
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,8 @@
|
||||||
import ast
|
import ast
|
||||||
import unreal # noqa
|
import unreal # noqa
|
||||||
import pyblish.api
|
import pyblish.api
|
||||||
|
from openpype.hosts.unreal.api.pipeline import UNREAL_VERSION
|
||||||
|
from openpype.pipeline.publish import KnownPublishError
|
||||||
|
|
||||||
|
|
||||||
class CollectInstances(pyblish.api.ContextPlugin):
|
class CollectInstances(pyblish.api.ContextPlugin):
|
||||||
|
|
@ -23,8 +25,10 @@ class CollectInstances(pyblish.api.ContextPlugin):
|
||||||
def process(self, context):
|
def process(self, context):
|
||||||
|
|
||||||
ar = unreal.AssetRegistryHelpers.get_asset_registry()
|
ar = unreal.AssetRegistryHelpers.get_asset_registry()
|
||||||
instance_containers = ar.get_assets_by_class(
|
class_name = ["/Script/OpenPype",
|
||||||
"OpenPypePublishInstance", True)
|
"AssetContainer"] if UNREAL_VERSION.major == 5 and \
|
||||||
|
UNREAL_VERSION.minor > 0 else "OpenPypePublishInstance" # noqa
|
||||||
|
instance_containers = ar.get_assets_by_class(class_name, True)
|
||||||
|
|
||||||
for container_data in instance_containers:
|
for container_data in instance_containers:
|
||||||
asset = container_data.get_asset()
|
asset = container_data.get_asset()
|
||||||
|
|
@ -32,9 +36,8 @@ class CollectInstances(pyblish.api.ContextPlugin):
|
||||||
data["objectName"] = container_data.asset_name
|
data["objectName"] = container_data.asset_name
|
||||||
# convert to strings
|
# convert to strings
|
||||||
data = {str(key): str(value) for (key, value) in data.items()}
|
data = {str(key): str(value) for (key, value) in data.items()}
|
||||||
assert data.get("family"), (
|
if not data.get("family"):
|
||||||
"instance has no family"
|
raise KnownPublishError("instance has no family")
|
||||||
)
|
|
||||||
|
|
||||||
# content of container
|
# content of container
|
||||||
members = ast.literal_eval(data.get("members"))
|
members = ast.literal_eval(data.get("members"))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue