Author Topic: UIButton Disappears on tap in iOS and onHover in Unity Play Mode  (Read 5154 times)

dleight

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 6
    • View Profile
I have 4 UIButtons on a menu.  They all use alpha tween to appear on the home screen of my app.  In play mode, the last button "Help" disappears upon exiting onHover (i.e., it's still there during onHover but as soon as the mouse is moved, it disappears and will not return even if I move the mouse back over).  When publishing a test build to an iPad Air 2 running iOS 8.1.2, the Help button disappears after tapping.  I looked through the attributes of all buttons and they all look the same, but only the help button exhibits this behavior.

There is something else happening which I'll mention since it may be related. When a button is clicked, I overlay a sprite (which acts a page in the app) on top of the menu. When I go to one of these pages, I can see the buttons faintly in the background.

I am working on an update of my app and I checked the published version on the same iPad and there is no trace of this problem (i.e., everything works as expected).  The published version was running NGUI 3.5.1 and Unity 4.3.4, I believe. For the update, I am running Unity 4.6.2 and NGUI 3.8.

Any help is greatly appreciated - I'm trying to get this published for an event which is in a week and still will need to submit and get approval from Apple, so I need to fix this asap.  Thanks.

Gwl

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 8
    • View Profile
Re: UIButton Disappears on tap in iOS and onHover in Unity Play Mode
« Reply #1 on: March 04, 2015, 07:05:50 AM »
I think I have encountered the same issue, it's probably due to default button state getting alpha=0 in some situations (alpha changed before button init?) Anyway workaround for me was to use button.SetState(UIButtonColor.State.Normal, true) before any tweening (ie. alpha has to be still 1 when calling that).

dleight

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 6
    • View Profile
Re: UIButton Disappears on tap in iOS and onHover in Unity Play Mode
« Reply #2 on: March 04, 2015, 02:25:33 PM »
I think I have encountered the same issue, it's probably due to default button state getting alpha=0 in some situations (alpha changed before button init?) Anyway workaround for me was to use button.SetState(UIButtonColor.State.Normal, true) before any tweening (ie. alpha has to be still 1 when calling that).

Thank you Gwl. That sounds right. Mine starts at alpha 0 and tweens to 1 for a fade-in effect. Where did you put that statement? Did you create a custom script or add it in to one of the existing ones?  I haven't worked with NGUI much other than the standard, built-in stuff and even with that stuff it's been awhile.  Thanks for your help.

Gwl

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 8
    • View Profile
Re: UIButton Disappears on tap in iOS and onHover in Unity Play Mode
« Reply #3 on: March 04, 2015, 04:19:57 PM »
I had a custom script already as I'm doing the tweening using another lib in this case, so yeah custom. But I think this is really an NGUI bug which appeared at some point so hopefully it gets fixed in proper way.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIButton Disappears on tap in iOS and onHover in Unity Play Mode
« Reply #4 on: March 05, 2015, 10:07:20 PM »
This isn't a bug. Button tweens the color, and tween alpha also changes the color. You need to put tweens on different objects, like so:

UIWidget (collider, UI button, tween alpha)
- UISprite (background)
- UILabel (text)

The key is to have UIButton on UIWidget set to tween UISprite. Since UISprite is not the same widget as UIWidget, the tweens won't interfere.