Edit default 'Variable Name' of Actor Component

Hi,

Is it possible to edit the default variable name when an actor component is created in blueprint?

I’m aware of the DisplayName specifier in the UCLASS macro, but this only changes the name in the Add Component drop-down. The variable name is always the class name in code.

The ‘Variable Name’ variable is defined in BlueprintDetailsCustomization, so I don’t know how to access that from the object itself.

I have also tried using the Rename() function but that doesn’t change the blueprint’s variable name.

Hi Epok,

I am sorry, but no it is not possible to change the default variable name for newly added components. This is because the sequence of events that occurs after selecting a new component class essentially calls NewObject by passing in NAME_None for the object’s name. Doing so internally generates a new name for the component based off of its class name.

1 Like

Thanks for the info!

Is it not possible to change that name after creation either then? Say in OnComponentCreated?

Hi Epok,

I do not believe it is possible to change the name there, either. I wrote a small test that calls Rename in OnComponentCreated, and the created component still did not have the new name. Doing so also removed my ability to manually set the new component’s name. As long as you are okay with that, you may be able to successfully change the name by setting a timer to delay the call to Rename but that all seems like too much of a workaround to have a custom operation that changes the names of components.

Is there a reason you cannot just change the name of the component class itself?

Ah ok, not to worry then.

I am writing a plugin for the marketplace, and to avoid any class name clashes with other plugins, I have put a prefix in front of every class - it looks a bit ugly in the editor is all!

I have the same problem. Creating plugin with prefix. Were you able to figure this out?