- Home /
UI Button should stay highlighted on click
I have an issue where I need my button to stay highlighted after click, indicating that it is disabled (I already disabled it in the code). But I am unable to depict the same by using either color tint or sprite swap. When I used color tint, although the color stays after click, it goes away whenever i click on any other part of the screen. I tried using toggle, but it didn't work either.
I have same prblm but i have to use in buttons not toggle
Answer by daveinpublic · Nov 27, 2015 at 10:20 AM
You should be able to do it with toggle. Make 2 graphics, one for when it isn't selected, and one that's highlighted for when it is selected. In the toggle component, you'll see target graphic at the top, and graphic towards the bottom. Place both images in your scene in the same position, and then drag the unselected version in the target graphic slot, and the selected version in the graphic slot. I haven't done it in a little while, but I believe that's how you set it up. If you want the menu item to stay selected between game loads, store it in a playerpref and then set the toggle to true or false in the start function:
yourObject.GetComponent().isOn = true
Your answer
Follow this Question
Related Questions
Reset the last local players toggle button while keeping online players selection? 0 Answers
I'm trying to toggle my in-game menu. 1 Answer
Toggle Button Question 0 Answers
GUI.Button Toggling Error 1 Answer
Toggle Button State On/Off 2 Answers