• [UE4]多播代理


    1. 第一种

    DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FReceiveDelegateEvent, FString, Value1, FString, Value2);
    
    UPROPERTY(BlueprintAssignable, Category = "Event")
    FReceiveDelegateEvent  ReceiveDelegateEvent;
    UFUNCTION(BlueprintCallable, Category = "My|MyActor")
    void BroadcastToBluePrint(FString value1, FString value2);
    
    void AMyActor::BroadcastToBluePrint(FString value1, FString value2)
    {
      this->ReceiveDelegateEvent.Broadcast(value1, value2);
    }

    2.第二种

    .h

    // Fill out your copyright notice in the Description page of Project Settings.  
      
    #pragma once  
      
    #include "UObject/NoExportTypes.h"  
    #include "Kismet/BlueprintAsyncActionBase.h"  
    #include "MyObject.generated.h"  
      
    /** 
     *  
     */  
    UCLASS()  
    class TTTTT_API UMyObject : public UBlueprintAsyncActionBase  
    {  
        GENERATED_BODY()  
          
    public:  
      
        DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FTestDelegate, FString, Content, int32, StatusCode);  
      
        UFUNCTION(BlueprintCallable, Category = "MyObject")  
            static UMyObject* DDDelegate(FString url,  FString Content);  
      
        UPROPERTY(BlueprintAssignable)  
            FTestDelegate OnSuccess;  
      
        UPROPERTY(BlueprintAssignable)  
            FTestDelegate OnFail;  
    private:  
        void DDUseDelegate(bool bSucceeded);  
    };  

    .cpp

    // Fill out your copyright notice in the Description page of Project Settings.  
      
    #include "TTTTT.h"  
    #include "MyObject.h"  
      
    UMyObject* UMyObject::DDDelegate(FString url, FString Content)  
    {  
        UMyObject* Helper = NewObject<UMyObject>();  
      
        return Helper;  
    }  
      
    void UMyObject::DDUseDelegate(bool bSucceeded)  
    {  
        if (bSucceeded)  
        {  
            OnSuccess.Broadcast("",0);  
        }  
        else  
        {  
            OnFail.Broadcast("", 1);  
        }  
    }  

  • 相关阅读:
    css3 transform语法
    自我规范(待增加)
    对于闭包的自我理解
    canvas教程没讲的细节
    react新手教程井字棋游戏
    div自动填满剩余部分(等高布局)
    记录自己以后可能会使用到的想法
    Python__list 常用操作
    Python基础语法(四)-- 函数
    Python基础语法(三)-- 循环
  • 原文地址:https://www.cnblogs.com/timy/p/8683949.html
Copyright © 2020-2023  润新知