Skip to content

Commit

Permalink
Cleaned up the NUSaveStateData script.
Browse files Browse the repository at this point in the history
• Simplified the VariableIndex and Udon property get accessors in the Instruction class.
• Simplified code used to carry over a VariableIndex when changing the Udon behaviour.
  • Loading branch information
Nestorboy committed May 7, 2022
1 parent 030c7b4 commit db6048c
Showing 1 changed file with 3 additions and 14 deletions.
17 changes: 3 additions & 14 deletions Assets/Nessie/Udon/NUSaveState/Scripts/Mono/NUSaveStateData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,22 +109,14 @@ public class Instruction
[SerializeField] private UdonBehaviour udon;
public UdonBehaviour Udon
{
get
{
return udon;
}
get => udon;
set
{
udon = value;

Variables = value != null ? value.GetFilteredVariables(allowedTypes, ~NUExtensions.VariableType.Internal).ToArray() : new NUExtensions.Variable[0];
VariableLabels = PrepareLabels(Variables);

int newVariableIndex = Array.FindIndex(Variables, var => var.Name == Variable.Name);
if (newVariableIndex >= 0)
VariableIndex = Variables[newVariableIndex].Type == Variable.Type ? newVariableIndex : -1;
else
VariableIndex = newVariableIndex;
VariableIndex = Array.IndexOf(Variables, Variable);
}
}

Expand All @@ -134,10 +126,7 @@ public UdonBehaviour Udon
[SerializeField] private int variableIndex = -1;
public int VariableIndex
{
get
{
return variableIndex;
}
get => variableIndex;
set
{
variableIndex = value;
Expand Down

0 comments on commit db6048c

Please sign in to comment.