uint32 UMaterialGraphSchema::GetMaterialValueType(const UEdGraphPin* MaterialPin) { if (MaterialPin->Direction == EGPD_Output) { UMaterialGraphNode* OwningNode = CastChecked<UMaterialGraphNode>(MaterialPin->GetOwningNode()); return OwningNode->GetOutputType(MaterialPin); } else { UMaterialGraphNode_Base* OwningNode = CastChecked<UMaterialGraphNode_Base>(MaterialPin->GetOwningNode()); return OwningNode->GetInputType(MaterialPin); } }
bool UMaterialGraphSchema::ArePinsCompatible(const UEdGraphPin* InputPin, const UEdGraphPin* OutputPin, FText& ResponseMessage) const { UMaterialGraphNode_Base* InputNode = CastChecked<UMaterialGraphNode_Base>(InputPin->GetOwningNode()); UMaterialGraphNode* OutputNode = CastChecked<UMaterialGraphNode>(OutputPin->GetOwningNode()); uint32 InputType = InputNode->GetInputType(InputPin); uint32 OutputType = OutputNode->GetOutputType(OutputPin); bool bPinsCompatible = CanConnectMaterialValueTypes(InputType, OutputType); if (!bPinsCompatible) { TArray<FText> InputDescriptions; TArray<FText> OutputDescriptions; GetMaterialValueTypeDescriptions(InputType, InputDescriptions); GetMaterialValueTypeDescriptions(OutputType, OutputDescriptions); FString CombinedInputDescription; FString CombinedOutputDescription; for (int32 Index = 0; Index < InputDescriptions.Num(); ++Index) { if ( CombinedInputDescription.Len() > 0 ) { CombinedInputDescription += TEXT(", "); } CombinedInputDescription += InputDescriptions[Index].ToString(); } for (int32 Index = 0; Index < OutputDescriptions.Num(); ++Index) { if ( CombinedOutputDescription.Len() > 0 ) { CombinedOutputDescription += TEXT(", "); } CombinedOutputDescription += OutputDescriptions[Index].ToString(); } FFormatNamedArguments Args; Args.Add( TEXT("InputType"), FText::FromString(CombinedInputDescription) ); Args.Add( TEXT("OutputType"), FText::FromString(CombinedOutputDescription) ); ResponseMessage = FText::Format( LOCTEXT("IncompatibleDesc", "{OutputType} is not compatible with {InputType}"), Args ); } return bPinsCompatible; }