EpicGamesExt / BlenderTools

Blender addons that improve the game development workflow between Blender and Unreal.
https://epicgamesext.github.io/BlenderTools/
MIT License
2.75k stars 45 forks source link

Send2UE: When extensions change asset location paths, the Paths settings are still used internally #454

Open DanMcLaughlin opened 2 years ago

DanMcLaughlin commented 2 years ago

Addon: Send2UE Workflow: Export a skeletal mesh with rig and animations, all which shows up in a single custom subfolder, by using an extension Description:

In developing an extension - the latest which is pushed to the repo from my other Extension request if you want an example of the issue, I've found that the Paths setting is 'sticky', in that it appears to be used internally regardless of if an extension is attempting to entirely use different locations

image

With plain meshes it isn't an issue, the problem comes with moving full characters. In particular the skeleton is moved internally at some point, and there's no opportunity in an extension to determine where that goes. By default it appears to pick the Path's settings. However in my example, and I suspect probably the most common use case, is that most people/studios will put it all as a subfolder of the mesh, which most represents the character. I believe the Paragon characters are structured this way.

So the issue is I have two injections - mesh and animations, but the skeleton gets set by the Paths which may be anything. And if they're wrong it errors out because the directories probably haven't been created that are specified in those paths, or some other mixup. So I can change the paths - and I do, the best place being in the pre_operations, however since that's asset agnostic I don't know yet what they will be. In other words, if the use case is that I will have a structure something like as seen the in image above, I can't figure that out until I get to the pre_mesh_export, but by that time it appears the skeleton (at least) has already been prepped to whatever is in the Paths before pre_mesh_export.

I hope that makes sense ... basic issue is sending full characters with a fully specific name is fragile and easily breaks, due to internal dependencies on the Paths. Since asset placement is a major part of this, it might be better to break the two entirely and leave it up to the extension writer. In my case I would like to just write the finally determined locations to the Paths dialog so the artist has a reference to see where the extension decided to put it, based on the settings in the extension validations.

DanMcLaughlin commented 2 years ago

I don't know if this is a feature and a bug, and to be clear the structure I'm aiming for is the following. My example extension settings are

image

With these available settings

image

You can see the use case, some assets you just bang together and want to test, so they go into a Test folder. Eventually everything in there gets cleaned out. Some assets are just miscellaneous - general purpose maybe, anyhow there's a Misc folder for them to go into. And finally the production assets go into e.g. Game/Art/L01/SM_TheBoss_AssetTag/.... For characters an Animation subfolder is in there, and then the material, BP and such get dumped there too eventually. That location is determined solely from the name that the mesh has. We have an internal tool that generates these names, based on the tag which has traceability through our process from requirements to final assets. Further details are in the template I put up.

DanMcLaughlin commented 2 years ago

And by the way I'm able to work for the most part. It errors out when changing the status from say Test to Finished, and I want it to stage the assets in their final location. Problem being the Paths are still set up Test (OK I can manually go in there and change them but kind of defeats the purpose and is usually forgotten anyhow) and so it errors out. However it can be run again - now they are set correctly because the mesh portion ran, and it will run through correctly.

My template should work so you can try loading it up and seeing what I mean if you wish.

james-baber commented 2 years ago

Ok so I'm trying to understand your example.

{
 'asset_folder': '/Game/example_extension/test/',
 'asset_path': '/Game/example_extension/test/Cube1_added_this',
 'asset_type': 'MESH',
 'file_path': 'C:\\Users\\User~1\\AppData\\Local\\Temp\\blender\\send2ue\\data\\mesh\\Cube1_added_this.fbx',
 'import_mesh': True,
 'lods': None,
 'skeletal_mesh': False,
 'skeleton_asset_path': '',
 'sockets': {}
 }

In your pre_mesh_export and pre_animation_export are you saying that you are changing skeleton_asset_path and asset_folder path and it is not respecting those changes? Or is it that between pre_mesh_export and pre_animation_export changes don't carry over?

Also could you link the lines in your extension that your referring to?

DanMcLaughlin commented 2 years ago

Yeah I know it's hard to understand, I sat on this until I could get it to a point where I have an example but I'm not explaining it clearly. Here's an example of what I'm trying to accomplish

Game/A/B/C/SM_Boss/
Game/A/B/C/SM_Boss/Skeleton, Mesh, Physics
Game/A/B/C/SM_Boss/Animation/anim1, anim2, ...

How to accomplish this and get everything in the right place? It's a combination of settings the asset_data and self.unreal_mesh_folder_path properly. Here are the technicalities

james-baber commented 2 years ago

Ok yea I think I understand.

  1. pre_mesh_export and pre_animation_export wont share the same asset data dictionary since they are separate assets, and fbx files, import commands etc.
  2. A limitation of the Unreal FBXImportUI class is that the SkeletalMesh, Skeleton, and Physics assets are a package deal(although you can reference existing ones), meaning that they are all dumped into the same folder as the mesh, and this is how the FBX Import UI works from a user perspective too.

So if I am understanding correctly, you want to create a sub directory Skeleton and move your imported skeleton into it. So that has to be done retro actively in post_import. Making a small RPC function that does something like https://docs.unrealengine.com/5.0/en-US/PythonAPI/class/EditorAssetLibrary.html?highlight=make_directory#unreal.EditorAssetLibrary.make_directory and https://docs.unrealengine.com/5.0/en-US/PythonAPI/class/EditorAssetLibrary.html?highlight=make_directory#unreal.EditorAssetLibrary.rename_asset

And in the same way you would need to then move the SkeletalMesh asset into a Mesh folder. The animation import path on the other hand can be specified directly, since the FBXImportUI provides that interface.

Does that help?

DanMcLaughlin commented 2 years ago

On your points

  1. Correct - I understand and no problem. The only issue is that animations need to know where the mesh is and it's name to know where to go. Or - as I did above - the pre_mesh_export can set up the anim location ahead of time
  2. Not a problem

"So if I am understanding correctly, you want to create a sub directory Skeleton and move your imported skeleton into it"

No, I'm absolutely fine with it getting dumped with the rest of the stuff. The problem is that the location (for the skeleton) comes from 'self.unreal_mesh_folder_path', but my earliest opportunity to set that is only in pre_mesh_export.

Well let me continue with this, working with characters in an extension when moving the location is challenging due to all the assets and I need to refine what is causing me trouble. I'll either close this or come back with a better example.

Good thing is I'll have a template up spelling this out for others , there's subtleties to making this work.

james-baber commented 2 years ago

unreal_mesh_folder_path is really only useful for the pre_operation. Setting the asset data dictionary directly bypasses that. So it sounds like your wanting to have the extension dynamically change paths on the asset data dictionary. So the same logic your running to make the Mesh folder, you'll have to use to get your animation folder, and you'll need to set the skeleton path so it is correct, since your moving the mesh folder.

Might help if your did most of the work in post_import or post_operation(especially if your modifying import paths) just dump to a tmp folder in your project, then start moving the assets around, at least then you'd know where they are. Hopefully that helps

DanMcLaughlin commented 2 years ago

Ooooh, that's a good idea, yeah it's tricky trying to do it in the middle of the process. Yes, that would be much better, just collect everything and then move after all the information has been collected. Let me think on it a bit ..