OnComponentChangedAttribute
Declares a static method of a VisualElementComponentAttribute struct as the handler that runs when one of the component's fields changes on an element.
Read time 4 minutesLast updated 6 days ago
Definition
- Type: Class
- Namespace: UnityEngine.UIElements
- Assembly: UnityEngine.UIElementsModule
- Inherits from: Attribute
[AttributeUsage(AttributeTargets.Method, Inherited = false)]public class OnComponentChangedAttribute : Attribute
Remarks
The method must be , and a component may declare at most one. The source generator emits notifying setters for the component's fields; each one flags the owner so this handler runs once in the next update, no matter how many fields changed. Use it to invalidate the owner — for example , a layout request, or recomputing a cached value. The handler never runs from inside the setter, so a burst of writes in one frame coalesces into a single call.
static void M(ref T self, <see cref="UnityEngine.UIElements.VisualElement"></see> owner)SetXxx(ref T, VisualElement, value)owner.MarkDirtyRepaint()