码迷,mamicode.com
首页 > 其他好文 > 详细

UE4_创建一个异步蓝图节点

时间:2020-05-23 15:03:55      阅读:76      评论:0      收藏:0      [点我收藏+]

标签:async   let   多播   min   rem   context   copy   ble   other   

// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "Kismet/BlueprintAsyncActionBase.h"
#include "MyBlueprintAsyncActionBase.generated.h"

/*
*  这是申明的多播 也就是异步节点的输出引脚
*/
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FDoComplete, FString, Key);
/**
 * 创建节点需要继承 UBlueprintAsyncActionBase
 */
UCLASS()
class MYNULL_1_API UMyBlueprintAsyncActionBase : public UBlueprintAsyncActionBase
{
	GENERATED_BODY()

public:
	UMyBlueprintAsyncActionBase();

	UPROPERTY(BlueprintAssignable)
	FDoComplete DoComplete;

public:
/*
* BlueprintInternalUseOnly 只允许蓝图使用  蓝图调用的函数必须时静态的 不知道为什么
*/
	UFUNCTION(BlueprintCallable, Category = "MyThings", meta = (BlueprintInternalUseOnly = "true", WorldContext = "WorldContextObject"))
	static UMyBlueprintAsyncActionBase* DoThing(const FString Str);
/*
// Fill out your copyright notice in the Description page of Project Settings.


#include "MyBlueprintAsyncActionBase.h"

UMyBlueprintAsyncActionBase::UMyBlueprintAsyncActionBase()
{

}

UMyBlueprintAsyncActionBase* UMyBlueprintAsyncActionBase::DoThing(const FString Str)
{
	UMyBlueprintAsyncActionBase* BlueprintNode = NewObject<UMyBlueprintAsyncActionBase>();
	BlueprintNode->DoOther(Str,BlueprintNode);
	return BlueprintNode;
}

void UMyBlueprintAsyncActionBase::DoOther(const FString Str, UMyBlueprintAsyncActionBase* Async)
{
	UE_LOG(LogTemp, Log, TEXT("AAA"));
	Async->DoComplete.Broadcast(Str);
}

  

* 这是主要的函数 */ void DoOther(const FString Str, UMyBlueprintAsyncActionBase* Async); };

  

UE4_创建一个异步蓝图节点

标签:async   let   多播   min   rem   context   copy   ble   other   

原文地址:https://www.cnblogs.com/djw1993/p/12942371.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!