UPDATE
Now this is just my case but I have a Blueprint that has 3 components. The Root (SkeletalMesh), Texture Render and then a Plugin class I have. Anytime I call set_editor_property on any of those components, the rest essentially turn into TRASH_. My guess is that after setting a property for some reason this prompts unreal to throw away those references and make them TRASH.
What this allowed me to do was essentially split my logic up and constantly reset my components variable back after setting
def SetAttribute (Component=[],AtrName=''):
for assets in Component:
unreal.log(assets.get_name())
if assets.get_name() == 'NamePlate' and AtrName == 'NamePlate':
owner = assets.get_owner()
name = owner.get_actor_label()
assets.set_editor_property('Text', name)
# break
if assets.get_name() == 'MySkeleton' and AtrName == 'MySkeleton':
ActorPropToSet = assets
owner = assets.get_owner()
name = owner.get_actor_label()
unreal.log(owner)
assets.set_editor_property('Source_Skeleton_Asset_Name', name)
unreal.log(assets.get_name())
# break
def AddActor(actorname, file_path, character, POS=[0,0,0], ROT=[0,0,0]):
SpawnAsset = unreal.EditorAssetLibrary.find_asset_data(file_path + character)
unreal.EditorLevelLibrary.spawn_actor_from_object(SpawnAsset.get_asset(), POS, ROT)
ActorInScene = unreal.EditorLevelLibrary.get_selected_level_actors()
ActorInScene[0].set_folder_path('/Actors')
ActorInScene[0].set_actor_label(actorname)
Comps = ActorInScene[0].get_components_by_class(unreal.ActorComponent)
SetAttribute(Comps,'NamePlate')
Comps = ActorInScene[0].get_components_by_class(unreal.ActorComponent)
SetAttribute(Comps, 'OptitrackSkeleton')
The part where I am getting the components of my actor after setting the attributes is what ended up working for me. Again, seems like after you set a property, Unreal throws away the components and it’s references. For instance, if you were to try and get the owner of the component right after setting the property you will nothing.
Anyway, thought I would share as I imagine others might run into this. Would be great to get some feedback from Epic or anyone that knows more.