Color blending
The Range
attribute explored previously may be attached to integer and floating-point variables, by way of their declarations, to limit the accepted values for them between a minimum and maximum in the Unity Editor. In the Unity Editor, a slider control is substituted for an editable field that controls the accepted values for the variable. This does not, of course, affect the values assigned to the same variables in the code. In the code, at runtime, the Range
attribute has no effect itself. Rather, the Range
attribute simply controls how numerical public variables are presented in the Object Inspector, and how they are entered there via user input. Behind the scenes, an Editor
class is querying object Attribute
data through reflection to control how the data type is rendered in the Object Inspector.
The Range
attribute works well for numbers. But it'd be great to deploy similar behavior for other data types besides just numbers. For example, it's common to fade between different...