Is it posible to have Static Delegates?

Thank you, I’ll have to verify what to do so I can use this feature.

Hi everyone.

I have a Delegate that I need to use in a C++ Class that I have which is a BlueprintLibrary, this is the markup for my delegate:

DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FFruitAbailable, float, FruitAbailable);

And this is how I created the variables in the .h file:

UPROPERTY(BlueprintAssignable, Category = "Kingdom Manager UI")
		static FFruitAbailable FruitBroadcast;

And this is how I have created the variable in the .cpp file:

FFruitAbailable UKingdomManager::FruitBroadcast;

and this is the error I’m getting, can anybody help me with this issue?

Error: Unrecognized type ‘static’ -
type must be a UCLASS, USTRUCT or
UENUM CompilerResultsLog: Info Error:
UnrealHeade

Thank you.

No, static UPROPERTYs are not supported, regardless of type.

Blueprint libraries are not supposed to have any state, not even static data members. If you need a shared delegate like this, put it on a UObject as a non-static UPROPERTY, and control creation/access to that class so that there is only ever a single instance of it used.

1 Like

No. As you know… static UPROPERTYs are not supported by the engine. But you can find some solutions for this!
For example, if you need more than one static delegate, you might consider creating a static wrapper class where you will store your delegates. A game instance subsystem will be useful for this.
The game instance subsystem works as a static class that can be called from every blueprint and every part of your code. So if you declare your delegates in that class, that can help you. In fact, I just tried that solution and it worked without problems.