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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Question How do I prevent SetEnabled from changing the UI color?

Discussion in 'UI Toolkit' started by Amane224, May 20, 2022.

  1. Amane224

    Amane224

    Joined:
    May 4, 2016
    Posts:
    5
    When using UIToolkit at runtime, I want to switch between operable and inoperable states without changing the appearance.
    I thought SetEnabled would be preferable, but the UI is grayed out when disabled.
    I want to prevent the UI from accepting operations during fade-in.

    I apologize if my style of writing is impolite, as I used an automatic translation for the post.
     
  2. JuliaP_Unity

    JuliaP_Unity

    Unity Technologies

    Joined:
    Mar 26, 2020
    Posts:
    666
    Have you tried using readonly instead?
     
  3. Amane224

    Amane224

    Joined:
    May 4, 2016
    Posts:
    5
    This is the first time I have heard of such a function.
    I am sorry, but could you please tell me where I can operate it from?
    I tried searching the Scripting API and looking in the UI Builder section, but I couldn't find it.
     
  4. JuliaP_Unity

    JuliaP_Unity

    Unity Technologies

    Joined:
    Mar 26, 2020
    Posts:
    666
    I'm not sure which elements you're using, but for a TextField for example, you'll find "Readonly" in the Inspector section of the UI Builder
    Screen Shot 2022-05-20 at 14.43.37.png

    For elements that don't have the "Readonly" property though, you can adjust the style even in disabled style to not show as grayed out. By clicking the text box next to the "+" button on the StyleSheets section of the UI Builder you can see some information about complex selectors, and also on our documentation page.
     
    Amane224 likes this.
  5. Amane224

    Amane224

    Joined:
    May 4, 2016
    Posts:
    5
    I want to fade out the entire UI with an empty Visual Elment created in the root, so readonly does not seem to work.
    I will try the style adjustments you described.
    Thank you for your explanation.
     
    JuliaP_Unity likes this.