Search Unity

"Any Field Changed" event, or equiv

Discussion in 'UI Toolkit' started by MoruganKodi, Oct 31, 2019.

  1. MoruganKodi

    MoruganKodi

    Joined:
    Feb 11, 2015
    Posts:
    79
    Is there such an event, to check if any non-specific field in the heirarchy has changed?

    Effectively, I am looking for an equivelant of IMGUI's BeginChangeCheck/EndChangeCheck,
    but for UIElements (both editor and runtime to boot).

    Specifically this is needed for some dynamic and procedural layouts, to validate fields and determine if the UI should be rebuilt, and to avoid having to somehow cycle every single field to menually register/check if registered.
     
  2. wbahnassi_unity

    wbahnassi_unity

    Unity Technologies

    Joined:
    Mar 12, 2018
    Posts:
    28
  3. MoruganKodi

    MoruganKodi

    Joined:
    Feb 11, 2015
    Posts:
    79
    That would be real tricky for layouts where only part of the layout is dynamic and procedural, and the rest comes from UXML.
     
  4. uDamian

    uDamian

    Unity Technologies

    Joined:
    Dec 11, 2017
    Posts:
    1,231
    You could try registering for the
    ChangeEvent<type>
    , for a bunch of types you care about, on the container element of all the fields you're interested in capturing. Events bubble up the tree by default so it's possible to capture them in the parent, as long as no other child element eats them (by calling
    evt.StopPropagation()
    )
     
  5. tonycoculuzzi

    tonycoculuzzi

    Joined:
    Jun 2, 2011
    Posts:
    301
    this would be very useful. previously we had the GUI.onChanged flag to work with. this is missing functionality imo