How to run script after asset import into level?

At the moment I have a workflow problem with Unreal. I am using blender to sculpt some terrain (not a 2d heightfield just a typical 3d mesh) and place objects like trees, rocks and in-game items about. I run “import into level” and everything shows up under a single prefab, great! However, I need to perform manual steps to get the imported prefab + contents to behave properly for my game. Some steps include setting up the collision mesh properties (just uses the mesh as the collider), marking as block dynamic and then adding components for special named objects like “PlayerStart” or “PickUp”. I’m looking to hook in hopefully via c++, or python, so that after I export my FBX file in blender my custom asset importer catches the event and I can then automatically rig up things as desired via code.

Using the existing terrain tools is not viable for my design goals; please keep in mind that if answering :slight_smile:

Hey @oldhighscore, I see you’re looking to get into editor scripting! It’s great for getting your pipeline set up just right, I wish I had more specialized content to help out with, but in this case the documentation should point you in a good starting direction, from there you’ll have to get a bit more specific. I couldn’t find a baseline way to catch calls for say imports, but this will allow you to make operations to run on them once they are in. Hopefully this starting point helps out!

3 Likes

This set me on the right path, thanks!

import unreal
al = unreal.EditorAssetLibrary()
tas = al.load_asset("/Game/TestAsset")
tas.set_editor_property("complex_collision_mesh",tas)
bs = tas.get_editor_property('body_setup')
bs.set_editor_property('collision_trace_flag',unreal.CollisionTraceFlag.CTF_USE_COMPLEX_AS_SIMPLE)
al.save_loaded_asset(tas)
3 Likes