// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved. #include "GraphEditorCommon.h" #include "SGraphNodeMaterialResult.h" #include "TutorialMetaData.h" ///////////////////////////////////////////////////// // SGraphNodeMaterialResult void SGraphNodeMaterialResult::Construct(const FArguments& InArgs, UMaterialGraphNode_Root* InNode) { this->GraphNode = InNode; this->RootNode = InNode; this->SetCursor(EMouseCursor::CardinalCross); this->UpdateGraphNode(); } void SGraphNodeMaterialResult::CreatePinWidgets() { // Create Pin widgets for each of the pins. for( int32 PinIndex=0; PinIndex < GraphNode->Pins.Num(); ++PinIndex ) { UEdGraphPin* CurPin = GraphNode->Pins[PinIndex]; bool bHideNoConnectionPins = false; if (OwnerGraphPanelPtr.IsValid()) { bHideNoConnectionPins = OwnerGraphPanelPtr.Pin()->GetPinVisibility() == SGraphEditor::Pin_HideNoConnection; } const bool bPinHasConections = CurPin->LinkedTo.Num() > 0; //const bool bPinDesiresToBeHidden = CurPin->bHidden || (bHideNoConnectionPins && !bPinHasConections); UMaterialGraph* MaterialGraph = CastChecked(GraphNode->GetGraph()); check(PinIndex < MaterialGraph->MaterialInputs.Num()); const bool bPinDesiresToBeHidden = !MaterialGraph->MaterialInputs[PinIndex].IsVisiblePin(MaterialGraph->Material) || (bHideNoConnectionPins && !bPinHasConections); if (!bPinDesiresToBeHidden) { TSharedPtr NewPin = CreatePinWidget(CurPin); check(NewPin.IsValid()); NewPin->SetIsEditable(IsEditable); this->AddPin(NewPin.ToSharedRef()); } } } void SGraphNodeMaterialResult::MoveTo(const FVector2D& NewPosition, FNodeSet& NodeFilter) { SGraphNode::MoveTo(NewPosition, NodeFilter); RootNode->Material->EditorX = RootNode->NodePosX; RootNode->Material->EditorY = RootNode->NodePosY; RootNode->Material->MarkPackageDirty(); RootNode->Material->MaterialGraph->MaterialDirtyDelegate.ExecuteIfBound(); } void SGraphNodeMaterialResult::PopulateMetaTag(FGraphNodeMetaData* TagMeta) const { if( (GraphNode != nullptr) && (RootNode != nullptr) ) { UMaterialGraph* OuterGraph = RootNode->GetTypedOuter(); if (OuterGraph != nullptr) { TagMeta->OuterName = OuterGraph->OriginalMaterialFullName; // There is only one root node - so we dont need a guid. TagMeta->Tag = FName(*FString::Printf(TEXT("MaterialResNode_%s"), *TagMeta->OuterName)); TagMeta->GUID.Invalidate(); TagMeta->FriendlyName = FString::Printf(TEXT("Material Result node in %s"), *TagMeta->OuterName); } } }