C# attributes and reflection
From this point forward in the chapter, all editor extensions will rely heavily on the concepts of attributes and reflection. These concepts are not specific to Unity but refer to more general ideas in computer science, programming, and to their application in languages such as C# as well as in the .NET framework. Before proceeding to the next editor extension, let's consider attributes and the related concept of reflection using the example of the Range
attribute, which is native to Unity. Consider the following line of code:
public float MyNumber = 0;
This public variable will be displayed in the Object Inspector with an edit field that allows the user to type in any valid floating point number thereby setting the ...
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.