How to get the value LoopBehavior of Niagara SystemState?

HI All,

I try to get the value LoopBehavior of ​Niagara SystemState. However, the parameter value is empty. Maybe there’s lack of paratermeter intialization. I wonder how to get the value.

Thanks so much.

[Image Removed]

重现步骤
Here is the static funtion to get the value.

`void GatherNiagaraSystemUpdateScriptVariables(TSoftObjectPtr InSystem, TArray& OutVariables)
{
OutVariables.Empty();
UNiagaraScript* Script = InSystem->GetSystemUpdateScript();
UNiagaraScriptSource* Source = Cast(Script->GetLatestSource());
UNiagaraGraph* ScriptSourceGraph = Source->NodeGraph;
TArray<UEdGraphNode*> NodesToProcess = ScriptSourceGraph->Nodes;

TArray Result;
for (UEdGraphNode* Node : NodesToProcess)
{
if (IsValid(Node))
{
if (const UNiagaraNodeFunctionCall* NodeFunctionCall = Cast(Node))
{
UNiagaraScript* NodeScript = NodeFunctionCall->FunctionScript;
if (const UNiagaraScriptSource* NodeScriptSource = Cast(NodeScript->GetLatestSource()))
{
const UNiagaraGraph* NodeScriptSourceGraph = NodeScriptSource->NodeGraph;
OutVariables.Append(NodeScriptSourceGraph->FindStaticSwitchInputs());
}
}
}
}
}`

Hi Estelle,

First sorry for the late response, it looks similar to what I have done in some local code…

`const FName NAME_LoopBehavior(“Loop Behavior”);

TArray<UNiagaraNodeStaticSwitch*> StaticSwitches;
UNiagaraGraph* NiagaraGraph = SystemStateFunctionCall->GetCalledGraph();
NiagaraGraph->GetNodesOfClass(StaticSwitches);

auto FindStaticSwitch =
[&StaticSwitches](FName SwitchName) → UNiagaraNodeStaticSwitch*
{
for (UNiagaraNodeStaticSwitch* Switch : StaticSwitches )
{
if (Switch->InputParameterName == SwitchName)
{
return Switch;
}
}
return nullptr;
};

WeakLoopBehaviorSwitch = FindStaticSwitch(NAME_LoopBehavior);`This is something I haven’t checked, but I’m parsing the system state locally so for stateless emitters I can auto disable the script if it’s trivial to parse. Once you start to add dynamic inputs then it’s no longer possible, but for static values you should be fine.

Thanks,

Stu