File size: 887 Bytes
18a519f | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | namespace Unity.VisualScripting
{
/// <summary>
/// Forces saved variables to be saved to the PlayerPrefs.
/// This is useful on WebGL where automatic save on quit is not supported.
/// </summary>
[UnitCategory("Variables")]
public sealed class SaveVariables : Unit
{
[DoNotSerialize]
[PortLabelHidden]
public ControlInput enter { get; private set; }
[DoNotSerialize]
[PortLabelHidden]
public ControlOutput exit { get; private set; }
protected override void Definition()
{
enter = ControlInput(nameof(enter), Enter);
exit = ControlOutput(nameof(exit));
Succession(enter, exit);
}
private ControlOutput Enter(Flow arg)
{
SavedVariables.SaveDeclarations(SavedVariables.merged);
return exit;
}
}
}
|