c++ 虚幻引擎5.2 -试图在UE 5.2上构建我的插件,但错误无法引用-这是一个删除的函数显示

uqdfh47h  于 2023-05-24  发布在  其他
关注(0)|答案(1)|浏览(259)

我试图在UE 5.2上构建我的插件,但出现以下错误:
不能引用C++函数(在的第xx行声明)--它是一个已删除的函数
问题在于UBlackboardComponent的使用,我是这样定义的:

BBComponent = CreateDefaultSubobject<UBlackboardComponent>(TEXT("BlackBoardComp"));
UBlackboardData* const bbData = BehaviorTree->BlackboardAsset;
BBComponent->InitializeBlackboard(*bbData);

然后,当我尝试从UBlackboardComponent获取密钥时:

targetActorKey = BBComponent->GetKeyID("TargetActor");

我得到这个错误:
无法引用C++函数(在的第xx行声明)-它是已删除的函数
我不知道我是否可以分享UE代码,假设它是开源的,我将分享FBlackboard的代码:

// Copyright Epic Games, Inc. All Rights Reserved.

#pragma once

#include "UObject/NameTypes.h"

namespace FBlackboard
{
    const FName KeySelf = TEXT("SelfActor");

#ifdef AI_BLACKBOARD_KEY_SIZE_8
    // this is the legacy BB key size. Add AI_BLACKBOARD_KEY_SIZE_8 to your *.target.cs to enable it.
    using FKey = uint8;
    inline constexpr FKey InvalidKey = FKey(-1);
#else
    //the default BB key size is now 16
    struct FKey
    {
        constexpr FKey() = default;
        FKey(int32 InKey) {Key = IntCastChecked<uint16>(InKey); }
        constexpr FKey(uint16 InKey) : Key(InKey) {}
        constexpr FKey(uint8 InKey) = delete;
        constexpr operator int32() const { return Key; }
        constexpr operator uint16() const { return Key; }
        constexpr operator uint8() const = delete;
        constexpr bool operator==(const FKey& Other) const {return Key == Other.Key;}
        constexpr bool operator!=(const FKey& Other) const {return Key != Other.Key;}
    private:
        friend uint32 GetTypeHash(const FKey& Key);
        uint16 Key = static_cast<uint16>(-1);
    };

    inline constexpr FKey InvalidKey = FKey();

    inline uint32 GetTypeHash(const FKey& Key) { return ::GetTypeHash(Key.Key);}
#endif
}

有人能帮帮我吗?
非常感谢!
我试着改变电话:

targetActorKey = BBComponent->GetKeyID("TargetActor");

uint16 targetActorKey = BBComponent->GetKeyID("TargetActor");

但这并不奏效。

h79rfbju

h79rfbju1#

将返回值更改为uint16对我来说很有效。

相关问题