Author Topic: Button Problem  (Read 4612 times)

benuto

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 3
    • View Profile
Button Problem
« on: July 30, 2014, 05:09:10 AM »
Hi,
I made a fire button which works pretty standard with the OnPress function.
Example Code:

void OnPress(bool pressed) {
 isPressed = pressed;
}

void Update () {
 if(isPressed) {
  doSomething();
 } else {
  doSomethingElse();
}

Nothing fancy.
I tested the game on different devices Samsung Galaxy S3, S3 Mini, some older LG Optimus 3D device and a Galaxy Tab 4. It works on all devices, but on the S3 Mini the button sometimes won't register that it is hit or pressed or anything, but it's only this button, all other buttons are working as intended.

I'm using Unity Free 4.5.2f1 and NGUI 3.6.8.

Ben

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Button Problem
« Reply #1 on: July 30, 2014, 10:43:19 AM »
Enable Debug on the UICamera, see what the touch is over and what's intercepting it.

benuto

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 3
    • View Profile
Re: Button Problem
« Reply #2 on: July 30, 2014, 02:02:49 PM »
Done that, as long as the button is working debug tells me last hit was on the button. Nothing intercepting. It's some strange behaviour, it works almost all the time, then it just stops, sometimes for a few seconds and then it works again and so forth. As mentioned this only happens on the Mini device. It feels like lag, but the rest of the game is running perfectly smooth.

Ben

beermoney

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 2
  • Posts: 80
    • View Profile
Re: Button Problem
« Reply #3 on: July 30, 2014, 03:00:06 PM »
I've seen something similar when the depth of the button widget (or possible the z position? I forget) is the same as another widget. On one platform it works fine but on others it's a little random.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Button Problem
« Reply #4 on: July 31, 2014, 10:52:00 AM »
Z has no effect when using the "UI" type events on UICamera. Have you tried moving the button around? Maybe the device itself is glitchy in regards to touch in that specific part of the screen.

benuto

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 3
    • View Profile
Re: Button Problem
« Reply #5 on: July 31, 2014, 02:28:02 PM »
The button is in the lower right corner of the screen, I moved it higher and made the collider a little bigger... same problem. To check if there was something with the touches I enabled the option to show touches on the phone in the developer options and played a few rounds. And it looks like the problem isn't ngui related after all, sometimes the phone didn't recognize the touch in the lower right corner, it happend a lot less with the touch trace option enabled. So you were right with the glitching. I'll have to move the button some more.

Thanks for the help!

Ben