#contents

----

UE 4.14.0ではEQSのテストはBlueprintで作成出来ない。
C++が必要になるのでその手順メモ。

* 参考 [#xd5b71b4]
エンジンのソースコードの下記辺りに既存のテストclassが有る
Engine\Source\Runtime\AIModule\Classes\EnvironmentQuery\Tests\


* 作り方 [#z058c67d]
+ C++クラスを作成する
&ref(eqs_create_test01.png,,70%);
+ 右上の「Show All Classes」にチェック、親クラスを「EnvQueryTest」を指定する。
&ref(eqs_create_test02.png,,70%);
+ そのまま作成を進めてC++ファイルを追加する。Visual Studioで開かれる。
+ ヘッダーは下記のように。
 UCLASS()
 class UMyEnvQueryTest : public UEnvQueryTest
 {
 	GENERATED_UCLASS_BODY()
 	
 
 	// テストを行う
 	virtual void RunTest(FEnvQueryInstance& QueryInstance) const override;
 
 	virtual FText GetDescriptionTitle() const override;
 	virtual FText GetDescriptionDetails() const override;
 };
+ ソースコードもいい感じに
 #include "EnvironmentQuery/Items/EnvQueryItemType_VectorBase.h"
 
 UMyEnvQueryTest::UMyEnvQueryTest(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer)
 {
 	// testのコスト?
 	Cost = EEnvTestCost::Low;
 
 	// アイテムは何のパラメーターを受け取れるか。多分。
 	ValidItemType = UEnvQueryItemType_VectorBase::StaticClass();
 }
 
 void UMyEnvQueryTest::RunTest(FEnvQueryInstance& QueryInstance) const
 {
 	// オーナーが居ない
 	UObject* QueryOwner = QueryInstance.Owner.Get();
 	if (QueryOwner == nullptr)
 	{
 		return;
 	}
 
 	FloatValueMin.BindData(QueryOwner, QueryInstance.QueryID);
 	float MinThresholdValue = FloatValueMin.GetValue();
 
 	FloatValueMax.BindData(QueryOwner, QueryInstance.QueryID);
 	float MaxThresholdValue = FloatValueMax.GetValue();
 
 	// アイテムの数だけブン回す
 	float score = 0.0f;  // いい感じにする
 	for (FEnvQueryInstance::ItemIterator It(this, QueryInstance); It; ++It)
 	{
 		score += 0.05f;  // いい感じにする
 		It.SetScore(TestPurpose, FilterType, score, MinThresholdValue, MaxThresholdValue);
 	}
 }
 
 FText UMyEnvQueryTest::GetDescriptionTitle() const
 {
 	return Super::GetDescriptionTitle();
 }
 
 FText UMyEnvQueryTest::GetDescriptionDetails() const
 {
 	return DescribeFloatTestParams();
 }


    ホーム 一覧 単語検索 最終更新 バックアップ リンク元   ヘルプ   最終更新のRSS