diff --git a/Source/ColorRamp/Private/MaterialExpressionColorRamp.cpp b/Source/ColorRamp/Private/MaterialExpressionColorRamp.cpp index 0993518..d64fd2a 100644 --- a/Source/ColorRamp/Private/MaterialExpressionColorRamp.cpp +++ b/Source/ColorRamp/Private/MaterialExpressionColorRamp.cpp @@ -16,6 +16,15 @@ UMaterialExpressionColorRamp::UMaterialExpressionColorRamp(const FObjectInitiali MenuCategories.Add(LOCTEXT( "Gradient", "Gradient" )); } +void UMaterialExpressionColorRamp::RebuildOutputs() +{ + Outputs.Reset(1); + bShowOutputNameOnPin = false; + Outputs.Add(FExpressionOutput(TEXT(""))); +} + +#if WITH_EDITOR + int32 UMaterialExpressionColorRamp::Compile(FMaterialCompiler* Compiler, int32 OutputIndex) { int32 AlphaIndex = Alpha.Expression ? Alpha.Compile(Compiler) : Compiler->Constant(ConstAlpha); @@ -92,41 +101,41 @@ TArrayView UMaterialExpressionColorRamp::GetInputsView() switch (PinType) { - case EPinType::ShowColorPinsDistributed: - case EPinType::ShowColorPins: - for (FColorRampPoint& Point : ColorPoints) - { - CachedInputs.Add(&Point.Color); - } - break; + case EPinType::ShowColorPinsDistributed: + case EPinType::ShowColorPins: + for (FColorRampPoint& Point : ColorPoints) + { + CachedInputs.Add(&Point.Color); + } + break; - case EPinType::ShowPositionPins: - for (FColorRampPoint& Point : ColorPoints) - { - CachedInputs.Add(&Point.Position); - } - break; + case EPinType::ShowPositionPins: + for (FColorRampPoint& Point : ColorPoints) + { + CachedInputs.Add(&Point.Position); + } + break; - case EPinType::ShowAllPinsGroup: - for (FColorRampPoint& Point : ColorPoints) - { - CachedInputs.Add(&Point.Color); - } - for (FColorRampPoint& Point : ColorPoints) - { - CachedInputs.Add(&Point.Position); - } - break; + case EPinType::ShowAllPinsGroup: + for (FColorRampPoint& Point : ColorPoints) + { + CachedInputs.Add(&Point.Color); + } + for (FColorRampPoint& Point : ColorPoints) + { + CachedInputs.Add(&Point.Position); + } + break; - case EPinType::ShowAllPinsAlternate: - for (FColorRampPoint& Point : ColorPoints) - { - CachedInputs.Add(&Point.Color); - CachedInputs.Add(&Point.Position); - } - break; - default: - break; + case EPinType::ShowAllPinsAlternate: + for (FColorRampPoint& Point : ColorPoints) + { + CachedInputs.Add(&Point.Color); + CachedInputs.Add(&Point.Position); + } + break; + default: + break; } return CachedInputs; @@ -252,7 +261,6 @@ FName UMaterialExpressionColorRamp::GetInputName(int32 InputIndex) const return NAME_None; } -#if WITH_EDITOR void UMaterialExpressionColorRamp::PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) { RebuildOutputs(); @@ -293,12 +301,6 @@ void UMaterialExpressionColorRamp::PostEditChangeProperty(FPropertyChangedEvent& Super::PostEditChangeProperty(PropertyChangedEvent); } -void UMaterialExpressionColorRamp::RebuildOutputs() -{ - Outputs.Reset(1); - bShowOutputNameOnPin = false; - Outputs.Add(FExpressionOutput(TEXT(""))); -} #endif #undef LOCTEXT_NAMESPACE \ No newline at end of file diff --git a/Source/ColorRamp/Public/MaterialExpressionColorRamp.h b/Source/ColorRamp/Public/MaterialExpressionColorRamp.h index c0143b8..1f5c090 100644 --- a/Source/ColorRamp/Public/MaterialExpressionColorRamp.h +++ b/Source/ColorRamp/Public/MaterialExpressionColorRamp.h @@ -55,8 +55,6 @@ class UMaterialExpressionColorRamp : public UMaterialExpression { GENERATED_UCLASS_BODY() -public: - UPROPERTY(meta = (RequiredInput = "false", ToolTip = "Defaults to 'ConstAlpha' if not specified")) FExpressionInput Alpha; @@ -72,18 +70,16 @@ class UMaterialExpressionColorRamp : public UMaterialExpression UPROPERTY(EditAnywhere, Category = "MaterialExpressionColorRamp") TArray ColorPoints; + void RebuildOutputs(); + #if WITH_EDITOR virtual void PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) override; - void RebuildOutputs(); -#endif - virtual int32 Compile(class FMaterialCompiler* Compiler, int32 OutputIndex) override; virtual void GetCaption(TArray& OutCaptions) const override; virtual TArrayView GetInputsView() override; virtual FExpressionInput* GetInput(int32 InputIndex) override; virtual FName GetInputName(int32 InputIndex) const override; virtual uint32 GetInputType(int32 InputIndex) override { return MCT_Float; } - -private: static int32 ApplyEaseInOutInterpolation(FMaterialCompiler* Compiler, int32 AlphaIndex, int32 PrevPositionIndex, int32 PositionIndex); +#endif };