x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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

Product Version: Not Selected
Tags:
more ▼

asked May 05 '15 at 10:50 PM in C++ Programming

avatar image

Feed_Dante
1 1 3 4

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

2 answers: sort voted first

Sorry to hear about the error, but please note, that in the described situation (https://forums.unrealengine.com/showthread.php?56537-Tutorial-How-to-accept-wildcard-structs-in-your-UFUNCTIONs&p=206131#post206131), array isn't being connected directly to Any Struct pin, since this is done for the appropriate struct.

Hope this was helpful!

more ▼

answered May 07 '15 at 07:51 AM

avatar image

Andrii Melnyk
1.9k 60 20 112

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

Hello, Feed_Dante

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:

https://forums.unrealengine.com/showthread.php?5324-Templated-Blueprint-functions

Hope this was helpful! Have a great day!

more ▼

answered May 06 '15 at 07:48 AM

avatar image

Andrii Melnyk
1.9k 60 20 112

avatar image Feed_Dante May 06 '15 at 10:10 AM

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.

avatar image Feed_Dante May 07 '15 at 06:02 AM

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.

alt text ('Locations' is simply an array of transforms.)

untitled.png (41.9 kB)
avatar image me4dinosaur Oct 23 '18 at 08:39 PM

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

avatar image Feed_Dante Oct 24 '18 at 07:12 PM

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.

code.txt (2.5 kB)
(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question