继承于UBlueprintAsyncActionBase的类,异步输出节点的实现方法,代码测试正常
.h文章来源:https://www.toymoban.com/news/detail-618092.html
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "Kismet/BlueprintAsyncActionBase.h"
#include "MyTwoParam.generated.h"
/**
*
*/
DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FResponsDeleget,int32,ID,FString,Data);
UCLASS()
class SPLINEPOINT_API UMyTwoParam : public UBlueprintAsyncActionBase
{
GENERATED_BODY()
public:
UPROPERTY(BlueprintAssignable)
FResponsDeleget Onsuccess;
UPROPERTY(BlueprintAssignable)
FResponsDeleget OnFail;
UPROPERTY()
int temp = 0;
UFUNCTION(BlueprintCallable, meta = (BlueprintInternalUseOnly = "true"))
static UMyTwoParam* MyClassAsyncActionBase(const int32 ID);
virtual void Activate() override;
};
.cpp文章来源地址https://www.toymoban.com/news/detail-618092.html
// Fill out your copyright notice in the Description page of Project Settings.
#include "MyTwoParam.h"
UMyTwoParam* UMyTwoParam::MyClassAsyncActionBase(const int32 ID)
{
UMyTwoParam* NewFeroxNode = NewObject<UMyTwoParam>();
NewFeroxNode->temp = ID;
return NewFeroxNode;
}
void UMyTwoParam::Activate()
{
//Super::Activate();
if (temp>0)
{
Onsuccess.Broadcast(temp,"success! from c++");
}
else
{
OnFail.Broadcast(-228,"Fail");
}
SetReadyToDestroy();
}
到了这里,关于UE5自定义蓝图节点(二)的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!