Unity Properties is a system that allows you to explore and modify the properties of C# types at runtime. It uses a visitor-style API that traverses the properties of an object graph in a predictable, controllable way.
You can use Unity Properties to read from or write to C# types generically, with minimal type-specific handling. This allows you to work with custom, user-defined C# types and, for example, to validate them, or convert them between different representations.
Unity Properties makes it possible to avoid or minimize reflection, which is relatively slow, allocates memory (which increases garbage collector overhead), and has limited support, especially on platforms that require ahead-of-time (AOT) compilation with IL2CPPA Unity-developed scripting back-end which you can use as an alternative to Mono when building projects for some platforms. More info
See in Glossary.
Unity Properties can be useful for the following common scenarios:
The Unity Properties framework has the following fundamental features that you can use to handle C# type data generically:
IPropertyBag<T> describes the fields and properties of type T. Unity generates property bags so the system can enumerate properties of your type.Visit<TContainer, TValue>. The framework traverses the container’s properties and invokes your logic per property.Vector3, enums, collections).For more detailed examples that use these features together, refer to Use PropertyVisitor to create a property visitor and Use low level APIs to create a property visitor.