mirror of
https://github.com/Eragon-Brisingr/UShaderLab.git
synced 2026-09-15 23:04:37 +00:00
Fix -Game no matieral error
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
// Copyright UShaderLab. All Rights Reserved.
|
||||
|
||||
#include "MaterialExpressionShaderLabParameterAnchor.h"
|
||||
|
||||
#include "MaterialCompiler.h"
|
||||
|
||||
UMaterialExpressionShaderLabParameterAnchor::UMaterialExpressionShaderLabParameterAnchor(const FObjectInitializer& ObjectInitializer)
|
||||
: Super(ObjectInitializer)
|
||||
{
|
||||
}
|
||||
|
||||
#if WITH_EDITOR
|
||||
TArrayView<FExpressionInput*> UMaterialExpressionShaderLabParameterAnchor::GetInputsView()
|
||||
{
|
||||
CachedInputs.Reset(Inputs.Num());
|
||||
for (FExpressionInput& Input : Inputs)
|
||||
{
|
||||
CachedInputs.Add(&Input);
|
||||
}
|
||||
return CachedInputs;
|
||||
}
|
||||
|
||||
FExpressionInput* UMaterialExpressionShaderLabParameterAnchor::GetInput(int32 InputIndex)
|
||||
{
|
||||
return Inputs.IsValidIndex(InputIndex) ? &Inputs[InputIndex] : nullptr;
|
||||
}
|
||||
|
||||
FName UMaterialExpressionShaderLabParameterAnchor::GetInputName(int32 InputIndex) const
|
||||
{
|
||||
return FName(*FString::Printf(TEXT("Param%d"), InputIndex));
|
||||
}
|
||||
|
||||
int32 UMaterialExpressionShaderLabParameterAnchor::Compile(FMaterialCompiler* Compiler, int32 OutputIndex)
|
||||
{
|
||||
// Compiled in the before-attributes pass. Compiling each input forces its static-switch selector
|
||||
// (and the selected `#define`-emitting Custom node) to compile here — emitting `#define <Switch> 0/1`
|
||||
// for the current permutation ahead of every body's `#if`. The returned value is unused.
|
||||
int32 Last = INDEX_NONE;
|
||||
for (FExpressionInput& Input : Inputs)
|
||||
{
|
||||
if (Input.GetTracedInput().Expression)
|
||||
{
|
||||
const int32 Code = Input.Compile(Compiler);
|
||||
if (Code != INDEX_NONE)
|
||||
{
|
||||
Last = Code;
|
||||
}
|
||||
}
|
||||
}
|
||||
return Last != INDEX_NONE ? Last : Compiler->Constant(0.0f);
|
||||
}
|
||||
|
||||
void UMaterialExpressionShaderLabParameterAnchor::GetCaption(TArray<FString>& OutCaptions) const
|
||||
{
|
||||
OutCaptions.Add(TEXT("ShaderLab Static-Switch Defines / Parameter Anchor"));
|
||||
}
|
||||
#endif // WITH_EDITOR
|
||||
Reference in New Issue
Block a user