So my question is:
How shall I modify ‘OnGrab’ to make it appear inside of owning Actor? just like OnComponentActivated/Deactivated events
Can I somehow achieve it with DECLARE_EVENT, DECLARE_DELEGATE macros ?
If you searching the already existing available event ‘OnComponentActivated’ from the UE source then you can find something like multicast delegate blahblah~.
I can’t answer your question but how about start from there?
@Polysiens
I think you’ve missunderstood my question or I don’t understand your answear :v
I don’t want to “call” this event from Owning Actor. I just want to “add” it to Owning Actor (and call it from the Component itself).
/* Lines 100-101 */
DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_TwoParams(FActorComponentActivatedSignature, UActorComponent, OnComponentActivated, UActorComponent*, Component, bool, bReset);
DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_OneParam(FActorComponentDeactivateSignature, UActorComponent, OnComponentDeactivated, UActorComponent*, Component);
/* Lines 386-392 */
/** Called when the component has been activated, with parameter indicating if it was from a reset */
UPROPERTY(BlueprintAssignable, Category = "Components|Activation")
FActorComponentActivatedSignature OnComponentActivated;
/** Called when the component has been deactivated */
UPROPERTY(BlueprintAssignable, Category = "Components|Activation")
FActorComponentDeactivateSignature OnComponentDeactivated;
I’ll check it later and give the proper response.
Thanks!
Well well well, the DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE was the way to go.
It’s probably an overkill in this case but it works xD There might be more optimal way to implement it though.
Few notes worth mentioning
This behaves just like a regular delegate when trying to access it inside of inhereted component (in Blueprints). Not an issue in my case.
DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE and UPROPERTY (used as Delegate) have to be declared as public.
Wasn’t able to find the exact documentation about “Dynamic Multicast Sparse Delegate”. Delegates page doesn’t really mention about it (or I was too impatient to find it). I’ve just followed the code from ActorComponent.h
Posting snipped of my code as example
.h
class UGrabbingComponent;
DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_OneParam(FOnGrab, UGrabbingComponent, OnGrab, AProp*, GrabbedProp);
UCLASS(ClassGroup=(Custom), meta=(BlueprintSpawnableComponent), Blueprintable )
class MyProject_API UGrabbingComponent : public USceneComponent
{
GENERATED_BODY()
public:
UPROPERTY(BlueprintAssignable)
FOnGrab OnGrab;
};