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. Voting for the Unity Awards are OPEN! We’re looking to celebrate creators across games, industry, film, and many more categories. Cast your vote now for all categories
    Dismiss Notice
  3. Dismiss Notice

UI button color setting

Discussion in 'Scripting' started by antoniomiguelferreiraaires, Jun 8, 2018.

  1. antoniomiguelferreiraaires

    antoniomiguelferreiraaires

    Joined:
    Apr 10, 2018
    Posts:
    53
    Hi. I have three buttons that are invisible (they have an white image icon behind it) and when clicked they display another color blue (image) which is the image attached to the button. They stay with that color when clicked and if I click again they get invisible again.
    Problem is: when I click on another button I want that button that was blue/displaying the other image to remain like that. What is happening right now is that the button image turns invisible if I click on them or I click anywhere else (another button for example). I'll leave a screen-shot of the buttons all invisible and white icons ON and one with one ON with the blue image, respectively. Thanks




     
  2. GroZZleR

    GroZZleR

    Joined:
    Feb 1, 2015
    Posts:
    3,201
  3. antoniomiguelferreiraaires

    antoniomiguelferreiraaires

    Joined:
    Apr 10, 2018
    Posts:
    53
  4. GroZZleR

    GroZZleR

    Joined:
    Feb 1, 2015
    Posts:
    3,201
    If you mean continue to use UI.Button and then also add this on top, not really -- at least not elegantly. The UI.Button will try to reset the graphic on mouse enters / exits while your code fights to keep it highlighted.
     
  5. antoniomiguelferreiraaires

    antoniomiguelferreiraaires

    Joined:
    Apr 10, 2018
    Posts:
    53
    Got it. How can I do that color change effect with script?
     
  6. antoniomiguelferreiraaires

    antoniomiguelferreiraaires

    Joined:
    Apr 10, 2018
    Posts:
    53
    Used OnPointerClick ty