Author Topic: [SOLVED] Stop UIButton from changing sprite  (Read 3019 times)

Laursen

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 7
    • View Profile
[SOLVED] Stop UIButton from changing sprite
« on: August 27, 2014, 02:08:35 AM »
EDIT: I solved it by modifying the UIButton script to include a condition "spriteSwitch" to evaluate before trying to change the sprite of the object.

Hello everyone!

This is my first post, but here goes.

After updating NGUI from 3.6.x to 3.7.1, I have noticed that the component UIButton contains functionality to change the sprite of the object to represent the states "Normal", "Hover", "Pressed" and "Disabled". (See attachment)

My problem is that I manually update my buttons when I click them, and want them to stay that way. (Think button for sound on/off that needs to retain the changed sprite) Because of this new functionality, I assume, my sprite keeps changes to the starting sprite from "Normal" state, whenever my mouse exists the object, causing whatever change of sprite I have made, to be overridden.

Is there any way to disable sprite switching on UIButtons?

Kind regards,
Laursen
« Last Edit: August 27, 2014, 02:31:55 AM by Laursen »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: [SOLVED] Stop UIButton from changing sprite
« Reply #1 on: August 27, 2014, 04:26:59 AM »
Consider simply switching to UIButtonColor instead of UIButton.

Laursen

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 7
    • View Profile
Re: [SOLVED] Stop UIButton from changing sprite
« Reply #2 on: August 27, 2014, 07:40:10 AM »
I would have done this, if my GUI wasn't allready set up to use the On Notify from the button component :)

But I will definitely consider it next time, thanks!