ez gui change texture at runtime

How do I change the texture of an ezgui uiButton from its atlas during runtime. I found out that u need to call the .SetTexture () but im still confused on how to call this and what to do with it.

Thank you

To implement what you describe, I’d use a State Toggle Button. This type of button allows you to define any number of states, and to set the graphic for each state. For what you describe, you would only need two states. After attaching the State Toggle Button component, select it in the hierarchy and open the UI Control Editor from Unity’s Windows menu. You can drag and drop your two states into the editor. The second state will use your weapon graphic. This control will now toggle between the two states when pressed. If necessary, you can prevent the button from returning to its original state with a bit more work.