赞
踩
目录
- //调用函数
-
- TWeakObjectPtr<AGWAnalysisToolBase> _bpActor;
- //方法1,外部设置字符串
- FString param = TEXT("arg1");
- FString cmdReset = TEXT("func1 ") + param ;
- //函数名+" "+参数(只能是简单参数,如string,int32等,
- //不能是枚举、结构体,函数名和参数使用空格隔开)
- FOutputDeviceNull device;
- _bpActor->CallFunctionByNameWithArguments(
- cmdReset,
- device,
- NULL,
- true);
- //方法2,直接调用
- _bpActor->CallFunctionByNameWithArguments(
- TEXT("func2"),
- device,
- NULL,
- true);
-
-
-
-
- //修改变量值,
- //示例为bool,所以使用FBoolProperty
-
- for (TFieldIterator<FBoolProperty> boolProperty((_bpActor.Get())->GetClass()); boolProperty; ++boolProperty)
- {
- if (boolProperty->GetName().Contains(TEXT("bVar1")))
- {
- boolProperty->SetPropertyValue_InContainer(_bpActor.Get(), true);
- }
- }
- //重点
- //1:需要被蓝图重写的函数需要使用BlueprintNativeEvent修饰
- //2:这个函数还需要添加一个虚函数,XXXXXX+[_Implementation],用于子类的重写,
- //为固定格式,亦或可以称为UE版本的虚函数吧
-
- UFUNCTION(BlueprintNativeEvent, Category = "BP| fun1")
- bool fun1();
- virtual bool fun1_Implementation() { return false; };
- UFUNCTION(BlueprintNativeEvent, Category = "BP| fun2")
- bool fun2();
- virtual bool fun2_Implementation() { return false; };
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。