Download

Making attached component editable

No doubt there are some routines in the engine for doing that kind of property and subobject copying, but I’m afraid I’ve not tried anything similar myself so can’t help you there.

I’d be wary of going that route though - you open up a world of pain whenever Epic make any changes to the engine’s AStaticMeshActor class.
If I’m understanding right that all you really need to add is editor interaction functionality and not any custom data or logic to the actors, you really want to avoid making any changes to the makeup of the actors in the level. Your best bet would be to make an editor extension that just provided a new tool window for manipulating the selected actor (if compatible). But yeah, anything like that is quite an effort, especially the first time.

Yeah, as I looked into it it became obvious that I should just add a dropdown that knows about the currently selected actor or component. It’s either deal with the pain of framework **** or the pain of slate. Neither is a great option but the latter should eventually work consistently.

Did you ever get this figured out? I’ve been running into the same issue… And I’ve narrowed it down to why it’s not working, but I’m looking for a workaround.

You can edit the component only if you declare it in the header file first… However if you declare an array of components, they are not editable for some reason… Which is what I’m trying to work through right now.

Same here ! one year later :smiley:
Did you find a solution ?

Best regards

As far as I know there’s no solution.

I know it’s an old thread but just in case for anyone looking for a solution, here’s mine:



Actor->SetRootComponent(Component);
Actor->AddInstanceComponent(Component); // call AddInstanceComponent after attaching it to an actor


If a component adds dynamically and you need editable fields in the details panel, then after NewObject you need to use

comp-> CreationMethod = EComponentCreationMethod::Instance;

Sometimes you need to use RemoveOwnedComponent and AddOwnedComponent


spawnActor-> RemoveOwnedComponent (comp);
comp-> CreationMethod = EComponentCreationMethod::Instance;
spawnActor-> AddOwnedComponent (comp);

Example:

FActorSpawnParameters Params;
AActor *spawnActor = World->SpawnActor(AActor::StaticClass(), Params);

UInstancedStaticMeshComponent *comp = NewObject< UInstancedStaticMeshComponent>(spawnActor);
spawnActor->SetRootComponent(comp);

spawnActor->RemoveOwnedComponent(comp);
comp->CreationMethod = EComponentCreationMethod::Instance;
spawnActor->AddOwnedComponent(comp);

comp->SetMobility(EComponentMobility::Movable);
comp->RegisterComponent();

Result

1 Like