このチャプターの目次
概要
ややこしいの抜きにしてノードを追加する。
値を二つ受け取って比較結果を返す。
結果
こういうやつ
内容
UEC++を用意
ただのノードのみなので、Blueprint Function Libraryを用いて作成
コード
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "Kismet/BlueprintFunctionLibrary.h"
#include "MyBlueprintFunctionLibrary.generated.h"
UENUM(BlueprintType)
enum class EComparison : uint8
{
Equal,
Less,
Higher
};
/**
*
*/
UCLASS()
class UE5_1_CTEST_API UMyBlueprintFunctionLibrary : public UBlueprintFunctionLibrary
{
GENERATED_BODY()
UFUNCTION(BlueprintCallable, Category = "Custom|Math|int", meta = (ExpandEnumAsExecs = "Comparison"))
static void Int32Comparison(EComparison& Comparison, int32 a, int32 b)
{
if (a > b)
{
Comparison = EComparison::Higher;
}
else if (a < b)
{
Comparison = EComparison::Less;
}
else
{
Comparison = EComparison::Equal;
}
};
};
こんな感じで用意。
弄った部分
UENUM(BlueprintType)
enum class EComparison : uint8
{
Equal,
Less,
Higher
};
UFUNCTION(BlueprintCallable, Category = "Custom|Math|int", meta = (ExpandEnumAsExecs = "Comparison"))
static void Int32Comparison(EComparison& Comparison, int32 a, int32 b)
{
if (a > b)
{
Comparison = EComparison::Higher;
}
else if (a < b)
{
Comparison = EComparison::Less;
}
else
{
Comparison = EComparison::Equal;
}
};
弄って追加した部分はここのみです。他はc++作成時に自動的に作成されます。
UENUM(BlueprintType)
おそらく、列挙型を用意する宣言のようなものかと思います。
UFUNCTION(BlueprintCallable, Category = "Custom|Math|int", meta = (ExpandEnumAsExecs = "Comparison"))
おそらく、ノードを用意する宣言のようなものかと思います。
Category
カテゴリの内容によって、ブループリントで検索して出てくる際の階層を示しているかと思います。
ExpandEnumAsExecs
これがあるかどうかで出力ピンの形が変わります。(ちょっとノード変わります。)
ある場合
UFUNCTION(BlueprintCallable, Category = "CustomFunction", meta = (ExpandEnumAsExecs = "OfTen"))
static void SwitchIntMultipleOfTen(EOfTen& OfTen, int number);
ない場合
UFUNCTION(BlueprintCallable, Category = "CustomFunction")
static void SwitchIntMultipleOfTen(EOfTen& OfTen, int number);