Firstborn/Library/PackageCache/com.unity.visualscripting@1.../Runtime/VisualScripting.Flow/Ports/ValueInputDefinition.cs
Schaken-Mods 9092858a58 updated to the latest editor
I updated everything to the latest Unity Editor. Also realized I had the wrong shaders on my hairs, those are fixed and the hairs look MUCH better!
2023-05-07 17:43:11 -05:00

68 lines
1.7 KiB
C#

using System;
namespace Unity.VisualScripting
{
public sealed class ValueInputDefinition : ValuePortDefinition, IUnitInputPortDefinition
{
[SerializeAs(nameof(defaultValue))]
private object _defaultvalue;
[Inspectable]
[DoNotSerialize]
public override Type type
{
get
{
return base.type;
}
set
{
base.type = value;
if (!type.IsAssignableFrom(defaultValue))
{
if (ValueInput.SupportsDefaultValue(type))
{
_defaultvalue = type.PseudoDefault();
}
else
{
hasDefaultValue = false;
_defaultvalue = null;
}
}
}
}
[Serialize]
[Inspectable]
public bool hasDefaultValue { get; set; }
[DoNotSerialize]
[Inspectable]
public object defaultValue
{
get
{
return _defaultvalue;
}
set
{
if (type == null)
{
throw new InvalidOperationException("A type must be defined before setting the default value.");
}
if (!ValueInput.SupportsDefaultValue(type))
{
throw new InvalidOperationException("The selected type does not support default values.");
}
Ensure.That(nameof(value)).IsOfType(value, type);
_defaultvalue = value;
}
}
}
}