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"

How to create custom event with array of structs as output node in Blueprint from C++

I defined the following delegate in C++

 DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FHostsReceivedDelegate, TArray<FHost>, Hosts);

And exposed it as a property

  UPROPERTY(BlueprintAssignable)
  FHostsReceivedDelegate HostsReceivedHandler;

In my BP I try to create a custom event to bind to it, but will get an error. With a different delegate it worked using FString and int32 as output types.

alt text

Is this even possible and if so, what needs to be changed?

Product Version: UE 4.15
Tags:
capture.jpg (120.1 kB)
more ▼

asked Mar 08 '17 at 02:16 PM in C++ Programming

avatar image

Mingah
58 4 6 11

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

1 answer: sort voted first

The declaration needs to be:

 DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FReceivedHostsDelegate, TArray<FHost>, Hosts);
more ▼

answered Mar 08 '17 at 06:23 PM

avatar image

Mingah
58 4 6 11

avatar image Socke81 Jul 18 '17 at 01:15 PM

Nope. "Server.h(30): error : Missing '<' in 'tarray'" if i try: DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FUserServerDataDelegate, const TArray&, action);

avatar image Mingah Jul 18 '17 at 01:34 PM

You are right. I have edited the code. Even though it is the same as I gave in my question, I think in the end it was how I was binding the event in BP was wrong.

avatar image Socke81 Jul 18 '17 at 01:45 PM

EDIT OK, i have it.

h

 //Delegates
 DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FUserServerDataDelegate, const TArray<FString>&, data);
 
 
 UFUNCTION()
     void UserServerDataDelegate(const TArray<FString>& data);
 UPROPERTY(BlueprintAssignable, Category = "0_UserData")
     FUserServerDataDelegate onUserServerDataDelegate;

cpp

 UServer::UServer()
 {
     //Delegate
     onUserServerDataDelegate.AddDynamic(this, &UServer::UserServerDataDelegate);
 }
 
 /*Delegate functions*/
 void UServer::UserServerDataDelegate(const TArray<FString>& data) {}




avatar image Mingah Jul 18 '17 at 02:06 PM

Nice, good work!

(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