This sort of works: i have to get the generated class, then the CDO.
And i can modify the static mesh on the cdo IF it was created in a C++ constructor.
But apparently a manually added static mesh component is not in the CDO.
So how can i get to it ?
Either i find a way to add it to the CDO, or i can get directly to the BP and not to the CDO of its generated class.
I tried to create a child BP from my template BP, hoping that the component would appear in the CDO of the child BP (inheriting from a BP already having this component), but no luck.
I also tried to use the AddStaticMeshComponent in the BP constructor, but it doesn’t work either.
Anyone has any idea of how i can add a component to the CDO without modifying the C++ constructor ?
How would i modify the CDO of a BP in a BP-only project (no C++) ?
I found a strange workaround to my problem but with a twist.
Continuing my tests, i found that, although i couldn’t act on components, i could actually act on variables.
For some reason, get_editor_property() and set_editor_property() method work on variables but not on component, although the doc says it should act on any property visible in the editor.
Anyone knows if this is normal or if this could be a bug to report ?
Anyway i defined a StaticMesh variable, and i can modify it in Python with this simple code:
bp_cdo.set_editor_property(“mesh”, actorMesh)
Now of course, since i’m only setting a variable, i have to assign it to the component.
Being atm unable to do it in python, i added this to the BP constructor:
This seems to do the job: i can set the mesh in Python without modifying my C++ class. I just have to assign it through BP scripting, which is acceptable for me.
So, problem almost solved, but there’s still a strange twist.
The mesh is assigned correctly and shows in the viewport, but it doesn’t appear as assigned in the component’s details panel (i tried many times to recompile, restart the editor, etc.).