Files
UnrealEngineUWP/Engine/Source/Editor/UnrealEd/Private/MaterialGraphNode_Root.cpp
Matt Kuhlenschmidt 9f83927366 Added a UI material domain for all Slate and UMG materials
- Automatically upgraded all materials

When using the UI material domain the material editor and material instance editor is streamlined and only displays parts of the UI that are relevant:
- Changes to a preview material rendered with the UI shader
- Removes non-UI specific settings
- Renames some output pins and hides irrelevant ones
- Shows stats for UI shader

[CL 2596027 by Matt Kuhlenschmidt in Main branch]
2015-06-22 15:55:50 -04:00

77 lines
2.1 KiB
C++

// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
/*=============================================================================
MaterialGraphNode_Root.cpp
=============================================================================*/
#include "UnrealEd.h"
#include "MaterialEditorUtilities.h"
#include "GraphEditorActions.h"
#include "GraphEditorSettings.h"
#define LOCTEXT_NAMESPACE "MaterialGraphNode_Root"
/////////////////////////////////////////////////////
// UMaterialGraphNode_Root
UMaterialGraphNode_Root::UMaterialGraphNode_Root(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer)
{
}
FText UMaterialGraphNode_Root::GetNodeTitle(ENodeTitleType::Type TitleType) const
{
return FMaterialEditorUtilities::GetOriginalObjectName(this->GetGraph());
}
FLinearColor UMaterialGraphNode_Root::GetNodeTitleColor() const
{
return GetDefault<UGraphEditorSettings>()->ResultNodeTitleColor;
}
FText UMaterialGraphNode_Root::GetTooltipText() const
{
return LOCTEXT("RootToolTip", "Description of final material inputs");
}
void UMaterialGraphNode_Root::PostPlacedNewNode()
{
if (Material)
{
NodePosX = Material->EditorX;
NodePosY = Material->EditorY;
}
}
void UMaterialGraphNode_Root::CreateInputPins()
{
UMaterialGraph* MaterialGraph = CastChecked<UMaterialGraph>(GetGraph());
const UMaterialGraphSchema* Schema = CastChecked<UMaterialGraphSchema>(GetSchema());
for (int32 Index = 0; Index < MaterialGraph->MaterialInputs.Num(); ++Index)
{
UEdGraphPin* InputPin = CreatePin(EGPD_Input, Schema->PC_MaterialInput, TEXT(""), NULL, /*bIsArray=*/ false, /*bIsReference=*/ false, MaterialGraph->MaterialInputs[Index].GetName().ToString());
}
}
int32 UMaterialGraphNode_Root::GetInputIndex(const UEdGraphPin* InputPin) const
{
for (int32 Index = 0; Index < Pins.Num(); ++Index)
{
if (InputPin == Pins[Index])
{
return Index;
}
}
return -1;
}
uint32 UMaterialGraphNode_Root::GetInputType(const UEdGraphPin* InputPin) const
{
UMaterialGraph* MaterialGraph = CastChecked<UMaterialGraph>(GetGraph());
return GetMaterialPropertyType(MaterialGraph->MaterialInputs[GetInputIndex(InputPin)].GetProperty());
}
#undef LOCTEXT_NAMESPACE