Files
UnrealEngineUWP/Engine/Source/Editor/UnrealEd/Classes/MaterialGraph/MaterialGraphNode.h
Josie Yang af65e53764 Inline edit support to material expression inputs
- Inline edit support for UPROPERTY of type float, int32, uint32, uint8, enum, bool.
- Editable UPROPERTYs with "OverridingInputProperty" metadata are created as inline widgets next to their corresponding inputs.
- Rest of the editable UPROPERTYs may specify "ShowAsInputPin" metadata to become inline edit pins, with 2 choices: "Primary" - show in primary view, "Advanced" - show in in advanced view.
- Update a bunch of material expressions to reflect the changes, rest of the expressions still need to be worked through.

#jira UE-145276
#rb kevin.Ortegren
#preflight 627a3cc8937a047d62282ba7

[CL 20122451 by Josie Yang in ue5-main branch]
2022-05-10 09:53:13 -04:00

112 lines
4.3 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "UObject/ObjectMacros.h"
#include "MaterialGraph/MaterialGraph.h"
#include "MaterialGraph/MaterialGraphNode_Base.h"
#include "MaterialGraphNode.generated.h"
class UEdGraphPin;
UCLASS(MinimalAPI)
class UMaterialGraphNode : public UMaterialGraphNode_Base
{
GENERATED_UCLASS_BODY()
/** Material Expression this node is representing */
UPROPERTY()
TObjectPtr<class UMaterialExpression> MaterialExpression;
/** Set to true when Expression Preview compiles, so we can update SGraphNode */
bool bPreviewNeedsUpdate;
/** Set to true if this expression causes an error in the material */
bool bIsErrorExpression;
/** Set to true if this expression is currently being previewed */
bool bIsPreviewExpression;
/** Checks if Material Editor is in realtime mode, so we update SGraphNode every frame */
FRealtimeStateGetter RealtimeDelegate;
/** Marks the Material Editor as dirty so that user prompted to apply change */
FSetMaterialDirty MaterialDirtyDelegate;
/** Called when the preview material attached to this graph node needs to be updated */
FSimpleDelegate InvalidatePreviewMaterialDelegate;
public:
/** Fix up the node's owner after being copied */
UNREALED_API virtual void PostCopyNode();
/** Get the expression preview for this node */
UNREALED_API FMaterialRenderProxy* GetExpressionPreview();
/** Recreate this node's pins and relink the Graph from the Material */
UNREALED_API void RecreateAndLinkNode();
/** Get the Material value type of an output pin */
//virtual uint32 GetOutputType(const UEdGraphPin* OutputPin) const override;
//~ Begin UObject Interface
virtual void PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) override;
virtual void PostEditImport() override;
virtual void PostDuplicate(bool bDuplicateForPIE) override;
//~ End UObject Interface
//~ Begin UEdGraphNode Interface.
virtual bool CanPasteHere(const UEdGraph* TargetGraph) const override;
virtual FText GetNodeTitle(ENodeTitleType::Type TitleType) const override;
virtual FLinearColor GetNodeTitleColor() const override;
virtual FText GetTooltipText() const override;
virtual void PrepareForCopying() override;
virtual void GetNodeContextMenuActions(class UToolMenu* Menu, class UGraphNodeContextMenuContext* Context) const override;
virtual void PostPlacedNewNode() override;
virtual void NodeConnectionListChanged() override;
virtual void OnRenameNode(const FString& NewName) override;
virtual void OnUpdateCommentText( const FString& NewComment ) override;
virtual void OnCommentBubbleToggled( bool bInCommentBubbleVisible ) override;
virtual void GetPinHoverText(const UEdGraphPin& Pin, FString& HoverTextOut) const override;
virtual FString GetDocumentationExcerptName() const override;
virtual bool CanUserDeleteNode() const override;
virtual uint32 GetPinMaterialType(const UEdGraphPin* Pin) const override;
virtual void PinDefaultValueChanged(UEdGraphPin* Pin) override;
//~ End UEdGraphNode Interface.
//~ Begin UMaterialGraphNode_Base Interface
virtual UObject* GetMaterialNodeOwner() const override { return MaterialExpression; }
virtual void CreateInputPins() override;
virtual void CreateOutputPins() override;
//~ End UMaterialGraphNode_Base Interface
/** Will return the shorten pin name to use based on long pin name */
static FName UNREALED_API GetShortenPinName(const FName PinName);
private:
/** Make sure the MaterialExpression is owned by the Material */
void ResetMaterialExpressionOwner();
/** Get the parameter name from the Material Expression */
FString GetParameterName() const;
/** Sets the Material Expression's parameter name */
void SetParameterName(const FString& NewName);
/** Should expression use the bool pin colour for its title */
static bool UsesBoolColour(UMaterialExpression* Expression);
/** Should expression use the float pin colour for its title */
static bool UsesFloatColour(UMaterialExpression* Expression);
/** Should expression use the vector pin colour for its title */
static bool UsesVectorColour(UMaterialExpression* Expression);
/** Should expression use the object pin colour for its title */
static bool UsesObjectColour(UMaterialExpression* Expression);
/** Should expression use the event node colour for its title */
static bool UsesEventColour(UMaterialExpression* Expression);
};