UE C++中获得蓝图函数返回值

IT 文章19秒前发布 小编
0 0 0

本文由优网导航(www.uonce.com)提供,主要讲解关于UE C++中获得蓝图函数返回值相关内容。

UE 反射应用

方法一:

ad

程序员导航

优网导航旗下整合全网优质开发资源,一站式IT编程学习与工具大全网站

	UFunction* bpFunc = ik_actor->GetClass()->FindFunctionByName(FName("GetReturnValue"));
	if (!bpFunc)
	{
		return -1;
	}
	struct EventFunc_Params
	{
		FString Args;
		FString ReturnValue;
	} Func_Params;

	ik_actor->ProcessEvent(bpFunc, &Func_Params);

方法二:

	UFunction* bpFunc = ik_actor->GetClass()->FindFunctionByName(FName("GetReturnValue"));
	if (!bpFunc)
	{
		return -1;
	}

	FStrProperty* returnValue = nullptr;
	for (TFieldIterator<UProperty> propIt(bpFunc, EFieldIteratorFlags::ExcludeSuper); propIt; ++propIt)
	{
		UProperty* property = *propIt;
		bool isOut = property->HasAnyPropertyFlags(CPF_ReturnParm | CPF_OutParm);
		if (!isOut)
		{
			continue;
		}

		FStrProperty* strProperty = CastField<FStrProperty>(property);
		if (strProperty)
		{
			returnValue = strProperty;
		}
	}

	FStructOnScope funcParam(bpFunc);
	ik_actor->ProcessEvent(bpFunc, funcParam.GetStructMemory());

	if (returnValue != nullptr && IsValid(bpFunc))
	{		
		FString value = returnValue->GetPropertyValue_InContainer(funcParam.GetStructMemory());
		if (value.IsEmpty())
		{
			GEngine->AddOnScreenDebugMessage(9840, 10.0, FColor::Red, "Value is Empty!", false);
		}
		else
		{
			FString Text = "Value is: " + value;
			GEngine->AddOnScreenDebugMessage(9840, 10.0, FColor::Red, Text, false);
			UE_LOG(LogTemp, Warning, TEXT("%s"), *value);
			return 0;
		}
	}

相关推荐: Git上有更新而本地无更新时的解决过程

本文主要讲解关于Git上有更新而本地无更新时的解决过程相关内容,由优网导航(www.uonce.com)提供,欢迎关注收藏本站! 问题分析 分支名称不匹配:你尝试推送到 main 分支,但你当前在 master 分支上 远程仓库有新内容:远程仓库包含你本地没有…

ad

AI 工具导航

优网导航旗下AI工具导航,精选全球千款优质 AI 工具集

© 版权声明

相关文章

暂无评论

暂无评论...