Search Unity

Question Runtime update style by code not work

Discussion in 'UI Toolkit' started by guodan, Jun 4, 2021.

  1. guodan

    guodan

    Joined:
    Dec 22, 2016
    Posts:
    29
    I want to hide a element by code. And I can get the element's reference. The method doesn't work just like the picture.
    upload_2021-6-4_17-16-40.png

    And I also try to modify "class", not work similarly.
    upload_2021-6-4_17-19-38.png

    Is there anything missing? I can manual set "display" by UI Toolkit Dubugger, and the UI works well. But how to do that by Script?
     
  2. Leslie-Young

    Leslie-Young

    Joined:
    Dec 24, 2008
    Posts:
    1,148
    Maybe I did not understand question but is this not what you are looking for? This is how I hide element. .....style.display = DisplayStyle.None;
     
  3. guodan

    guodan

    Joined:
    Dec 22, 2016
    Posts:
    29
    The problem is that the code doesn't work for me. And all modify element style by code don't work.
     
  4. guodan

    guodan

    Joined:
    Dec 22, 2016
    Posts:
    29
    update: What I manipulated element is out of screen, and I didn't noticed it. Now it's all right.