Author Topic: disabling UIImageButton  (Read 4143 times)

serioustommy

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 18
    • View Profile
disabling UIImageButton
« on: May 29, 2012, 12:09:05 PM »
Currently UIImageButton still responds to mouse events even when it's disabled. Is it possible to do the same fix as UIButtonScale, or is there a reason for this? Thanks!

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: disabling UIImageButton
« Reply #1 on: May 29, 2012, 02:25:56 PM »
Sure, change it like so:

  1. void OnHover (bool isOver)
  2. {
  3.         if (enabled && target != null)
  4.         {
  5.                 target.spriteName = isOver ? hoverSprite : normalSprite;
  6.                 target.MakePixelPerfect();
  7.         }
  8. }
  9.  
  10. void OnPress (bool pressed)
  11. {
  12.         if (enabled && target != null)
  13.         {
  14.                 target.spriteName = pressed ? pressedSprite : normalSprite;
  15.                 target.MakePixelPerfect();
  16.         }
  17. }

You will also see this change in the next update.