Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Change visibility of propertyfield when a different property changes

Discussion in 'UI Toolkit' started by pajamajama, Jul 22, 2021.

  1. pajamajama

    pajamajama

    Joined:
    Oct 22, 2012
    Posts:
    66
    I'm using CreateInspectorGUI() of a custom Editor.

    I have a property field that I only want to be drawn if another serialized bool is true. How do I do this?

    I've tried storing a reference to my root visual element, and updating it on property change events, but the inspector never reflects these updates. Do I need an additional call after I update the VisualElement to then redraw it?

    Thank you!
     
  2. pajamajama

    pajamajama

    Joined:
    Oct 22, 2012
    Posts:
    66
    storing a reference to the specific propertyfield that I want to change visibility on and setting the visibility on the seems to work in the value change callbacks.
     
  3. Kinggrass

    Kinggrass

    Joined:
    Jun 7, 2016
    Posts:
    66
    And how did you do that?