#pragma warning disable 618 namespace Unity.VisualScripting { [UnitShortTitle("Set Variable")] public abstract class SetVariableUnit : VariableUnit { protected SetVariableUnit() : base() { } protected SetVariableUnit(string defaultName) : base(defaultName) { } /// /// The entry point to assign the variable reference. /// [DoNotSerialize] [PortLabelHidden] public ControlInput assign { get; set; } /// /// The value to assign to the variable. /// [DoNotSerialize] [PortLabel("New Value")] [PortLabelHidden] public ValueInput input { get; private set; } /// /// The action to execute once the variable has been assigned. /// [DoNotSerialize] [PortLabelHidden] public ControlOutput assigned { get; set; } /// /// The value assigned to the variable. /// [DoNotSerialize] [PortLabel("Value")] [PortLabelHidden] public ValueOutput output { get; private set; } protected override void Definition() { base.Definition(); assign = ControlInput(nameof(assign), Assign); input = ValueInput(nameof(input)); output = ValueOutput(nameof(output)); assigned = ControlOutput(nameof(assigned)); Requirement(input, assign); Requirement(name, assign); Assignment(assign, output); Succession(assign, assigned); } protected virtual ControlOutput Assign(Flow flow) { var input = flow.GetValue(this.input); var name = flow.GetValue(this.name); GetDeclarations(flow).Set(name, input); flow.SetValue(output, input); return assigned; } } }