Why? DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam is marcro and TMap<int32, int32> has comma inside. So we can’t use that inside this macro. Preprocessor thinks int32> is next macro parameter (not an template parameter).
What I try?
#define COMBINE(a, ...) a, __VA_ARGS__
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FTestDelegate, COMBINE(TMap<int32, int32>), ParamName);
Not a chance:
error : Unrecognized type ‘COMBINE’ - type must be a UCLASS, USTRUCT or UENUM
error : Unrecognized type ‘FMyMap’ - type must be a UCLASS, USTRUCT or UENUM
So, the problem in Unreal Header Tool, that tool has no possibilities to bypass this trick(s).
I wish the UHT understood typedef or using keywords in parsing algorithms.
The typedef trick works with normal MULTICAST_DELEGATEs, but it seems that it doesn’t work with DYNAMIC_MULTICAST_DELEGATEs. Probably something with macro and UHT black magic.
I usually workaround it by creating a USTRUCT() with a TMap inside. Not the most elegant solution, but it works.
I’m trying t his solution, but unfortunately it’s not working. I am getting this error: Any ideas?
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FCSOnFindSessionsCompleteOther, const FSOnlineResult& SessionResults);
Error (active) E0077 this declaration has no storage class or type specifier
Unrecognized type ‘FSOnlineResult’ - type must be a UCLASS, USTRUCT or UENUM
USTRUCT(BlueprintType)
struct FSOnlineResult
{
GENERATED_USTRUCT_BODY()
UPROPERTY(BlueprintReadWrite)
TMap <int, FBlueprintSessionResult> SessionResults;
}
I’m trying t his solution, but unfortunately it’s not working. I am getting this error: Any ideas?
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FCSOnFindSessionsCompleteOther, const FSOnlineResult& SessionResults);
Error (active) E0077 this declaration has no storage class or type specifier
Unrecognized type ‘FSOnlineResult’ - type must be a UCLASS, USTRUCT or UENUM
USTRUCT(BlueprintType)
struct FSOnlineResult
{
GENERATED_USTRUCT_BODY()
UPROPERTY(BlueprintReadWrite)
TMap <int, FBlueprintSessionResult> SessionResults;
}
I have found how to hack Unreal Header Tool. A now it is possible to use TMap in multicast delegates legally, but with a lot of very black magic. Look here
We just can use DECLARE_DYNAMIC_MULTICAST_DELEGATE_*, but you must add comment at line above with backslash to cheat the UHT (compiler will ignore this line, but UHT is not)
But we must declare delegate manually with TMap type alias to actually create symbols.
Also we have to add macro from *.generated.h with generated info about this delegate (Look at red font in code example)
And finally we should #pragma disable warning 4010 to complile this code/get rid of warning.
This delegate can be used in Blueprints and C++. Try!