Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sure instance members are always list value for publishing uasset/Uasset loader can load the uasset #69

Merged
merged 7 commits into from
Sep 2, 2024
Merged
Show file tree
Hide file tree
Changes from 5 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
6 changes: 6 additions & 0 deletions client/ayon_unreal/api/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ def _default_collect_instances(self):
instance.get('creator_attributes', '{}'))
instance['publish_attributes'] = ast.literal_eval(
instance.get('publish_attributes', '{}'))
instance['members'] = ast.literal_eval(
instance.get('members', '[]'))
instance['families'] = ast.literal_eval(
instance.get('families', '[]'))
instance['active'] = ast.literal_eval(
instance.get('active', ''))
created_instance = CreatedInstance.from_existing(instance, self)
self._add_instance_to_context(created_instance)

Expand Down
18 changes: 7 additions & 11 deletions client/ayon_unreal/plugins/load/load_uasset.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
"""Load UAsset."""
from pathlib import Path
import os
import shutil

from ayon_core.pipeline import (
Expand Down Expand Up @@ -45,7 +46,6 @@ def load(self, context, name, namespace, options):
folder_path = context["folder"]["path"]
folder_name = context["folder"]["name"]
suffix = "_CON"
asset_name = f"{folder_name}_{name}" if folder_name else f"{name}"
tools = unreal.AssetToolsHelpers().get_asset_tools()
asset_dir, container_name = tools.create_unique_asset_name(
f"{root}/{folder_name}/{name}", suffix=""
Expand All @@ -66,9 +66,11 @@ def load(self, context, name, namespace, options):
"/Game", Path(unreal.Paths.project_content_dir()).as_posix(), 1)

path = self.filepath_from_context(context)
new_asset = os.path.basename(path)
new_asset_name = os.path.splitext(new_asset)[-1].lstrip(".")
moonyuet marked this conversation as resolved.
Show resolved Hide resolved
shutil.copy(
path,
f"{destination_path}/{name}_{unique_number:02}.{self.extension}")
f"{destination_path}/{new_asset}")

# Create Asset Container
unreal_pipeline.create_container(
Expand All @@ -81,7 +83,7 @@ def load(self, context, name, namespace, options):
"namespace": asset_dir,
"folder_path": folder_path,
"container_name": container_name,
"asset_name": asset_name,
"asset_name": new_asset_name,
"loader": str(self.__class__.__name__),
"representation": context["representation"]["id"],
"parent": context["representation"]["versionId"],
Expand All @@ -106,11 +108,8 @@ def update(self, container, context):

asset_dir = container["namespace"]

product_name = context["product"]["name"]
repre_entity = context["representation"]

unique_number = container["container_name"].split("_")[-2]

destination_path = asset_dir.replace(
"/Game", Path(unreal.Paths.project_content_dir()).as_posix(), 1)

Expand All @@ -124,11 +123,8 @@ def update(self, container, context):
unreal.EditorAssetLibrary.delete_asset(asset)

update_filepath = get_representation_path(repre_entity)

shutil.copy(
update_filepath,
f"{destination_path}/{product_name}_{unique_number}.{self.extension}"
)
new_asset_name = os.path.basename(update_filepath)
shutil.copy(update_filepath, f"{destination_path}/{new_asset_name}")

container_path = f'{container["namespace"]}/{container["objectName"]}'
# update metadata
Expand Down