UFunction, TArray wildcard input?

I currently have this:

UFUNCTION(BlueprintCallable, Category = "Statics", Meta = (ExpandEnumAsExecs = "Branches"))
static void BranchArrayHasMembers(const TArray<UObject*>& object, TEnumAsByte<TrueFalseEnum>& branches);

But it won’t work for things like an array of FTransform. (I’ve also tried TArray<UStruct*>.)
UFunctions don’t seem to like templates so I’m not sure how to achieve this here.

Essentially, I want something like the ADD function which will take an array of anything. How can I

Hello,

Please note, that support of templates in function arguments is quite limited now. Thus, this behavior should be handled at the node level. There is a wildcard pin type UEdGraphSchema::PC_Wildcard, which can be used to provide template-like functionality for array functions. When something is connected to a wildcard slot, the appropriate type is set for the rest of the wildcard dependent pins.

It is possible to make a custom subclass of UK2Node_CallFunction, and then allocate a wildcard parameter. In NotifyPinConnectionListChanged() function, you can determine if the pin that was connected was a wildcard and search for an UFunction for appropriate type, and then call UK2Node_SetFromFunction. This way, template-like behavior can be implemented.

However, there is also a way to receive wildcard parameters (USTRUCTs) without creating custom nodes. If you like to learn more about it, please go here:

Hope this was helpful! Have a great day!

I’m also not very familiar with C/C++. I’m used to Java/C#. If the answer is that I have to make a custom node then I’m at a loss without an example.

The function you reference seems to take any single property and uses a custom exec to analyze it:

UFUNCTION(BlueprintCallable, Category = "Example", CustomThunk, meta = (CustomStructureParam = "AnyStruct"))
static void ReceiveSomeStruct(UProperty* AnyStruct);
 
DECLARE_FUNCTION(execReceiveSomeStruct) {}

How would I change this to work for arrays? Or can UProperty be an array?
The code also uses ‘UArrayProperty’, can that be used as ‘any struct array’ similar to TArray<Uobject>?

I, unfortunately, won’t have time to try any of this till tonight but thank you for the help.

Ok, tried a big and got this:

Header:

UFUNCTION(BlueprintCallable, Category = "Statics", Meta = (CustomStructureParam = "anyStruct", ExpandEnumAsExecs = "Branches"))
static void BranchArrayHasMembers_Struct(UArrayProperty* anyStruct, TEnumAsByte<TrueFalseEnum>& branches);

Cpp:

void UStatics::BranchArrayHasMembers_Struct(UArrayProperty* anyStruct, TEnumAsByte<TrueFalseEnum>& branches) {
	auto size = anyStruct->GetSize();

	UE_LOG(LogBlueprintUserMessages, Log, TEXT("UArrayProperty size: %d"), size);

	if (size > 0) {
		branches = TrueFalseEnum::True_;
	}
	else {
		branches = TrueFalseEnum::False_;
	}
}

It compiles and I can link the nodes in the BP but I get this error:

Error Pin Any Struct is specified as an array, but does not have a valid array property.

(‘Locations’ is simply an array of transforms.)

Sorry to hear about the error, but please note, that in the described situation ([Tutorial] How to accept wildcard structs in your UFUNCTIONs - Community & Industry Discussion - Epic Developer Community Forums), array isn’t being connected directly to Any Struct pin, since this is done for the appropriate struct.

Hope this was helpful!

Did you ever make a workaround for accepting WildCard Variables/Array within UFunction?

It’s been years since I’ve looked at it so I can’t say for sure. I think I just made alternate functions that matched the type (I guess overloads didn’t work either).

I’ve attached most of the code so maybe that helps, maybe it doesn’t.