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 all 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
15 changes: 5 additions & 10 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,10 @@ def load(self, context, name, namespace, options):
"/Game", Path(unreal.Paths.project_content_dir()).as_posix(), 1)

path = self.filepath_from_context(context)
asset_name = os.path.basename(path)
shutil.copy(
path,
f"{destination_path}/{name}_{unique_number:02}.{self.extension}")
f"{destination_path}/{asset_name}")

# Create Asset Container
unreal_pipeline.create_container(
Expand Down Expand Up @@ -106,11 +107,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 +122,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