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 to change slider element via script

Discussion in 'UI Toolkit' started by UDN_04cab8b4-4f67-4f81-8ef9-dfdaac9aa5b8, Mar 2, 2023.

  1. UDN_04cab8b4-4f67-4f81-8ef9-dfdaac9aa5b8

    UDN_04cab8b4-4f67-4f81-8ef9-dfdaac9aa5b8

    Joined:
    Nov 1, 2016
    Posts:
    2
    Hello guy, I have problem with change slider element color via script. I want to change unity-dragger color at runtime. Anyone can help? slider.PNG
     
  2. SimonDufour

    SimonDufour

    Unity Technologies

    Joined:
    Jun 30, 2020
    Posts:
    529
    You will have to do a query (or multiples nested query depending on the complexity of your ui) and set the color as inline style on the object. We have currently no way of modifying the stylesheet at runtime.
     
  3. UDN_04cab8b4-4f67-4f81-8ef9-dfdaac9aa5b8

    UDN_04cab8b4-4f67-4f81-8ef9-dfdaac9aa5b8

    Joined:
    Nov 1, 2016
    Posts:
    2
    Thank you for your suggestion, i resolve by query class ".unity....dragger" and change first element found.