File size: 1,752 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 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | using System;
namespace Unity.VisualScripting
{
public sealed class ValueConnection : UnitConnection<ValueOutput, ValueInput>, IUnitConnection
{
public class DebugData : UnitConnectionDebugData
{
public object lastValue { get; set; }
public bool assignedLastValue { get; set; }
}
public override IGraphElementDebugData CreateDebugData()
{
return new DebugData();
}
[Obsolete(Serialization.ConstructorWarning)]
public ValueConnection() : base() { }
public ValueConnection(ValueOutput source, ValueInput destination) : base(source, destination)
{
if (destination.hasValidConnection)
{
throw new InvalidConnectionException("Value input ports do not support multiple connections.");
}
if (!source.type.IsConvertibleTo(destination.type, false))
{
throw new InvalidConnectionException($"Cannot convert from '{source.type}' to '{destination.type}'.");
}
}
#region Ports
public override ValueOutput source => sourceUnit.valueOutputs[sourceKey];
public override ValueInput destination => destinationUnit.valueInputs[destinationKey];
IUnitOutputPort IConnection<IUnitOutputPort, IUnitInputPort>.source => source;
IUnitInputPort IConnection<IUnitOutputPort, IUnitInputPort>.destination => destination;
#endregion
#region Dependencies
public override bool sourceExists => sourceUnit.valueOutputs.Contains(sourceKey);
public override bool destinationExists => destinationUnit.valueInputs.Contains(destinationKey);
#endregion
}
}
|