UClass* UK2Node_GetClassDefaults::GetInputClass(const UEdGraphPin* FromPin) const { UClass* InputClass = nullptr; const UEdGraphPin* ClassPin = FromPin; if(ClassPin == nullptr) { ClassPin = FindClassPin(); } if(ClassPin != nullptr) { check(ClassPin->Direction == EGPD_Input); if(ClassPin->DefaultObject != nullptr && ClassPin->LinkedTo.Num() == 0) { InputClass = CastChecked<UClass>(ClassPin->DefaultObject); } else if(ClassPin->LinkedTo.Num() > 0) { if(UEdGraphPin* LinkedPin = ClassPin->LinkedTo[0]) { InputClass = Cast<UClass>(LinkedPin->PinType.PinSubCategoryObject.Get()); } } } return InputClass; }
void UK2Node_GetClassDefaults::ReallocatePinsDuringReconstruction(TArray<UEdGraphPin*>& OldPins) { Super::ReallocatePinsDuringReconstruction(OldPins); // Recreate output pins based on the previous input class UEdGraphPin* OldClassPin = FindClassPin(OldPins); if(UClass* InputClass = GetInputClass(OldClassPin)) { CreateOutputPins(InputClass); } }
void UK2Node_GetClassDefaults::PostPlacedNewNode() { // Always exclude object array properties for new nodes. // @TODO - Could potentially expose object reference values if/when we have support for 'const' input pins. bExcludeObjectArrays = true; if(UEdGraphPin* ClassPin = FindClassPin(Pins)) { // Default to the owner BP's generated class for "normal" BPs if this is a new node const UBlueprint* OwnerBlueprint = GetBlueprint(); if(OwnerBlueprint != nullptr && OwnerBlueprint->BlueprintType == BPTYPE_Normal) { ClassPin->DefaultObject = OwnerBlueprint->GeneratedClass; } if(UClass* InputClass = GetInputClass(ClassPin)) { CreateOutputPins(InputClass); } } }