0
Not a Bug

Default value for ValueUnit for POCO type is not stored and marked as default value

Jeff Campbell 4 years ago updated by Lazlo Bonin (Lead Developer) 3 years ago 2

I have a ValueUnit on a custom unit of type Foo. I am initializing the ValueUnit using the overloaded method that allows for specifying a default value if the port is not connected. Upon debugging when this is initialized, the default value is not stored or marked as hacing a default value. Thus later on in the Flow delegate no value can be gotten for this ValueInput and an bolt error occurs specifying there is not a Foo value to be gotten or a default one to be had.

[Serializable]

public class Foo
{

}

Expected: A default POCO value can be set as the default in ValueUnit(key, default) and the property HasDefaultValue returns true and GetDefaultValue returns this value.

Actual: The default value is not stored and HasDefaultValue returns false and GetDefaultValue throws an error for no default value.

Bolt Version:
Unity Version:
Platform(s):
Scripting Backend:
.NET Version (API Compatibility Level):

Try changing Serializable to Inspectable and Generate inspectors. Which is the Serializer attribute you want for Bolt. This is what's used to allow inspectors for a type, which is also needed for literals and such. I'm not 100% if this is why, but I'm willing to bet it has something to do with it, as that's how you show default inspectors as well as other things.

Not a Bug

Not all types are allowed to be inlined as default values (this is by design).

You can, however, mark your class and any member you want to expose as [Inspectable] and then use a Foo Literal unit. (You don't need to generate inspectors for this to work).