I like the way I can drag and drop UStaticMesh properties. There’s also a way to open asset browser for such fields and start typing the name of the mesh.
What I want is to have the same way of referencing existing components.
For example I have components “first” and “second” both of the custom type inherited from UStaticMeshComponent and want to reference “first” from the second in the special field.
First that comes to my mind is to create a field like that
In this case when I click on this field in UI I see the list of types, not specific objects with names.
I can also create a text field like
but in this case I have no way of listing existing items in UI, only typing. It is potentially dangerous because provides no check for the existance of such name.
So is there actually a way to have a property which provides the list of names? Or can you imagine any workaround for such case?
There is FComponentReference, it’s been around forever but is barely known, probably because it’s not very helpful. It’s meant for this purpose, but apparently no-one at Epic thought this was important because it never received any nice customization to help with selecting components.
Essentially it’s the same as using a string property, it just automates the process of getting the specified component’s pointer in code, as well as making your code clearer.
We’ve been waiting for how long? 5? 6 years already?!
I was lurking in engine source today and found this. There’s no docs and I found only ONE place this thing is used!
Whoever did it forgot the tell everybody else about it:
I’ve tried it with “UseComponentPicket” however I don’t have a list of my components there. My components are all children of the same actor, this might be one of the issues.
As a workaround I made a different solution which cost me a day. I used Details panel customisation to create a combobox which i dynamically fill with strings.
static TArray<TSharedPtr<FString>> ComponentNames;
which i maintain in OnRegister, OnUnregister and PostRename of UStaticMeshComponent.
the picker won’t work on blueprints.
components on blueprints are archetypes, you can only pick on spawned actors in level.
To add on, I was fiddling around with other meta tags and found out there is also “AllowAnyActor”. I tested it out with FComponentReference and it appeared to work well, getting all actors in the scene. Combined with “AllowedClasses”, you may be able to filter only results that you want. I’ve only briefly tested this functionality so I am not sure if there are side effects to using this method.
In your .h file add this into your UCLASS
UCLASS(showCategories = ("Damage", "Wall"))
then in your UPROPERTY add this
UPROPERTY(EditAnywhere, SimpleDisplay, Category = "Wall")
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Damage")
int32 killTime = 10;
and it will show in your properties window on the right .
path to the file with all the settings.
When you add more settings into UCLASS. Do them one at a time as some do not work and want to error on compile. Same with UPROPERTY had a lot of them that do not seem to want to work and all they do is crash stuff. Not sure if it was the combo of what i was adding.
That’s quite limiting to work in instance placed in scene only. Is there any good way to get it working with blueprint now?