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"

Delegates container


I'm trying to create an EventContainer which can contain custom delegate (without specifing is it e.g. FExecuteEvent). The problem is with a proper type of it. I already tried with IDelegateInstance, TBaseDelegate and TBaseDynamicMulticastDelegate but importing them in multiple ways doesn't work.

Currently my function looks like this:

     UFUNCTION(BlueprintCallable, Category = "Event")
     virtual TArray<TBaseDelegate*> GetEvents() = 0;

And the import list:

 #include "Delegates\IDelegateInstance.h"
 #include "UObject\ScriptDelegates.h"
 #include "DelegateBase.h"
 #include "..\..\..\4.10\Engine\Source\Runtime\Core\Public\Delegates\DelegateSignatureImpl_Variadics.inl"

And the error:

 MultiEventContainer.h(27) : Unrecognized type 'TBaseDelegate' - type must be a UCLASS, USTRUCT or UENUM

Now, is there any way to make delegate be stored as such variable?

Product Version: UE 4.10
more ▼

asked Feb 20 '16 at 09:05 PM in C++ Programming

avatar image

1 5 5

avatar image Steve Robb STAFF Feb 22 '16 at 10:46 AM


You shouldn't be including those headers - they are correctly imported for you in Core.h, which is included by everything anyway.

There is no common base type for delegates - delegates are value types, not reference types - and so you shouldn't think of them in terms of pointers to base classes. Just like int and float don't have a common 'number' base class.

Maybe if you clarified what you are trying to do here, we could come up with a solution. You wouldn't be able to do anything with those delegates if there was a common base class, because there'd be no common signature to execute them. That's why you usually declare your delegate type in advance.

As Shadowriver says, only dynamic delegates are usable by the reflection system, so if you wanted to have a UFunction, you'd have to do something like:


 class UThing : public UObject

     virtual TArray<FMyEvent> GetEvents();

If you remove the UFUNCTION, you can make it a non-dynamic delegate, but the same issues with a lack of common base class remain.


avatar image ErgoAsh Feb 22 '16 at 11:25 AM

Well, yes, you're right. That was my own misconception.

I was trying to do the complex event system for my skills. The main concept was that I had an inteface called IAction and UActiveSkill implementing it. Action should have an FExecutionEvent delegate but intefaces cannot have variables so I tried to create IMultiEventContainer (with this GetEvents()). In theory I can store there (by overriding this in derived skills or actions) only one event but what if a skill contains more events? I wanted to store them all in this array and retrieve them using checkers but as you two said, there is no base class I can use.

After thinking about your comment, I'm going to delete IMultiEventContainer and I will:

  1. Make a IEventContainer< T > which will be storing a proper event (it will may be useful later) but only if you will be so kind to tell me how an interface can implement other interface or

  2. Just add GetEvent() to IAction

For additional events made in derived classes, I will simply make them in variables and execute them in server functions (simple is best...).

Great thanks for making me rethink what I have done.

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

2 answers: sort voted first

Thanks for help Shadowriver and Steve, my misconception is explained in comments.

more ▼

answered Feb 22 '16 at 11:27 AM

avatar image

1 5 5

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

This error means you using type that is not supported by reflection system

I dont see any use of TDelegateBase* in engine, i think it should be FDelegate and not pointer of it (reflection system can't handle pointers other then UObjects i think), try around those

As a last resort you can remove UPROPERTY() which will remove varable from reflection system and won't be parsed by UHT (thing that gives you error) and make nodes that operate this delegate. Removing something from reflection system also means it won't be managed by UE4 memory management systems.

more ▼

answered Feb 21 '16 at 01:33 AM

avatar image

37.2k 936 172 1116

(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