Skip to main content

Optional Attribute

An attribute for fields used to change their appearence in the Inspector. It marks them as optional fields to signal that they can remain unassigned without risk of causing errors. It does so by changing the label of applicable fields from 'Field Name' to '[Field Name]'.

Optional Attribute Usage Examples

note

It affects only string, UnityEngine.Object parameters and some Construct types (i.e. Id, TypeReference<T>.) It's ignored for any other serializable type.

warning

The actual checks that prevent a missing value from causing errors are up to the developer, it's not an automatic behavior of the attribute itself.