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 ...
Get Mastering Unity Scripting now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.