Hello Unreal Engine Community,
I’m currently facing an issue with a custom K2Node in Unreal Engine and seeking some assistance. I’ve created a custom node, UK2_FlexibleStruct
, but when I try to compile, I receive the following error:
.h file
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
//クラスをここでImport
#include "K2Node.h"
#include "KismetCompiler.h"
#include "K2Node_CallFunction.h"
#include "BlueprintActionDatabaseRegistrar.h"
#include "BlueprintNodeSpawner.h"
#include "EditorCategoryUtils.h"
#include "EdGraph/EdGraphNode.h"
//
#include "K2_FlexibleStruct.generated.h"
/**
*
*/
UCLASS(meta = (Keywords = "K2_FlexibleStruct"))
class UK2_FlexibleStruct : public UK2Node
{
GENERATED_BODY()
public:
virtual void AllocateDefaultPins() override;
virtual FLinearColor GetNodeTitleColor() const override;
virtual FText GetNodeTitle(ENodeTitleType::Type TitleType) const override;
virtual bool IsNodePure() const override;
virtual void GetMenuActions(FBlueprintActionDatabaseRegistrar& ActionRegistrar) const override;
virtual FText GetMenuCategory() const override;
};
.cpp file
#include "K2_FlexibleStruct.h"
namespace
{
static const FName CustomExecuteName(TEXT("A"));
}
/// <summary> Visual SettingsNode
FLinearColor UK2_FlexibleStruct::GetNodeTitleColor() const
{
float r = 242.0f/255.0f;
float g = 189.0f/255.0f;
float b = 27.0f/255.0f;
return FLinearColor(r, g, b,1.0f);
}
FText UK2_FlexibleStruct::GetNodeTitle(ENodeTitleType::Type TitleType) const
{
// 名前空間とキーを指定してローカライズ可能なテキストを生成する
return FText::FromString("FlexibleStruct");
}
FText UK2_FlexibleStruct::GetMenuCategory() const
{
// カテゴリ「Math」に登録する
return FEditorCategoryUtils::GetCommonCategory(FCommonEditorCategory::FlowControl);
}
/// </summary>
void UK2_FlexibleStruct::AllocateDefaultPins() { //..デフォルトのピンのコンテナの役割
const UEdGraphSchema_K2* K2Schema = GetDefault<UEdGraphSchema_K2>();
bCanRenameNode = 0;
CreatePin(EGPD_Input, TEXT("exec"), TEXT("execute"));
CreatePin(EGPD_Output, TEXT("then"), TEXT("thens"));
Super::AllocateDefaultPins();
}
bool UK2_FlexibleStruct::IsNodePure() const
{
return false;
}
void UK2_FlexibleStruct::GetMenuActions(FBlueprintActionDatabaseRegistrar& ActionRegistrar) const
{//..メニューをBPGraphから検索して表示されるようにする
UClass* ActionKey = GetClass();
if (ActionRegistrar.IsOpenForRegistration(ActionKey))
{
UBlueprintNodeSpawner* NodeSpawner = UBlueprintNodeSpawner::Create(GetClass());
check(NodeSpawner != nullptr);
ActionRegistrar.AddBlueprintAction(ActionKey, NodeSpawner);
}
}
Sorry there are some other language there, its some of my comment.
Only thing I did here was trying to make smallest node, that there has to be then and exec pin.
But It’s not working. Is there something I did wrong ? Or maybe I need some specific function for this situation or I need to add other pin to make my node work well?
I appreciate any help or guidance someone can provide. Thank you!
Edit:
I’m using UE5.2.1 and I implemented this node as runtime blank plugin inside my project.