У меня есть моя нода uk2node, которая принимает структуру, получает ее и класс, к…
- User
У меня есть моя нода uk2node, которая принимает структуру, получает ее и класс, к которому нужно привести возвращаемое нодой значение. Но объект для возврата из ноды я получаю из функции GetScen, а она принимает параметры класса и структуры, которые являются членами моего класса obj и objclass. Как мне передать эти свойства в параметры моей функции при вызове ноды внутри кода?
void UCustomK2Node::AllocateDefaultPins() { // Add execution pins CreatePin(EGPD_Input, UEdGraphSchema_K2::PC_Exec, UEdGraphSchema_K2::PN_Execute)->PinName = "lol";
CreatePin(EGPD_Output, UEdGraphSchema_K2::PC_Exec, UEdGraphSchema_K2::PN_Then)->PinName = "nelol";
CreatePin(EGPD_Input, UEdGraphSchema_K2::PC_Struct, FPathToScenarioObject::StaticStruct(), "Path");
CreatePin(EGPD_Output, UEdGraphSchema_K2::PC_Object, UObject::StaticClass(), FeaturePinName);
Super::AllocateDefaultPins(); }
void UCustomK2Node::PinConnectionListChanged(UEdGraphPin* Pin) { Super::PinConnectionListChanged(Pin);
if ( Pin->HasAnyConnections() && Pin->Direction == EEdGraphPinDirection::EGPD_Input && Pin->PinType.PinCategory == UEdGraphSchema_K2::PC_Struct ) { const auto GetterVarNode = Cast<UK2Node_VariableGet>(Pin->LinkedTo[0]->GetOwningNode());
UBlueprint* const OwningBlueprint = FBlueprintEditorUtils::FindBlueprintForNode(GetterVarNode); const FName VarName = GetterVarNode->VariableReference.GetMemberName(); UClass* const GeneratedClass = OwningBlueprint->GeneratedClass; UObject* const CDO = GeneratedClass->GetDefaultObject(); FProperty* const Property = FindFProperty<FProperty>(GeneratedClass, VarName); if ( !Property ) { return; } FStructProperty* const StructProperty = CastField<FStructProperty>(Property); if ( !StructProperty ) { return; } void* StructData = StructProperty->ContainerPtrToValuePtr<void>(CDO); Obj = *StaticCast<FPathToScenarioObject*>(StructData); if ( Obj.Path.IsEmpty() ) { return; } ObjClass = Cast<UScenarioObject>(Obj.Path.Last().Storage)->Classes; FindPin(FeaturePinName)->PinType.PinSubCategoryObject = ObjClass;} } void UCustomK2Node::ExpandNode(FKismetCompilerContext& CompilerContext, UEdGraph* SourceGraph) { Super::ExpandNode(CompilerContext, SourceGraph);
UEdGraphPin* ExecPin = FindPin(TEXT("lol")); UEdGraphPin* ThenPin = FindPin(TEXT("nelol")); UEdGraphPin* OutputPin = FindPinChecked(FeaturePinName);
UK2Node_CallFunction* CallFunctionNode = CompilerContext.SpawnIntermediateNode<UK2Node_CallFunction>(this, SourceGraph);
CallFunctionNode->FunctionReference.SetExternalMember(GET_FUNCTION_NAME_CHECKED(UCustomK2Node, GetScen), UCustomK2Node::StaticClass());
CallFunctionNode->AllocateDefaultPins();
auto strvalue = CallFunctionNode->FindPin(TEXT("str"));
CompilerContext.MovePinLinksToIntermediate(*ExecPin, *CallFunctionNode->GetExecPin()); CompilerContext.MovePinLinksToIntermediate(*ThenPin, *CallFunctionNode->GetThenPin());
- Assistant