Author Topic: OnClick, OnPress don't work on my iPad..  (Read 14524 times)

kaywoods

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 12
    • View Profile
OnClick, OnPress don't work on my iPad..
« on: January 28, 2013, 06:17:14 AM »
Hi..
I just beta-completed my project..using NGUI 2.2.3.. in a long ...journey...!!.. :P :P :P :P

The 'OnClick' and 'OnPress'  works on the my iMac PC...
I succeeded in the compiling Xcode after Unity's build and run..


But the 'Onclick' or 'OnPress' event doesn't work on the iPad...

They don't respond my touch event.. on the iPad..but they only works like on the MouseOver(changing color and size...)


- I used NGUI 2.2.3(the first version when I purchased..- I didn't upgraded after my purchasing because I'm afraid of the possibilities of compatiblility problems...)
- Xcode 4.5.2
- iPad2 : iOS 6.0.1
- Unity4 : v4.0.1f2

What's the cause of not working touch event on the iPad2 ???

##
I updated to the latest NGUI v2.3.1,, and compiled xcode downloaded to the iPad... But the result is the same ...

It works on the normally in the Unity Editor( Button OnClick...)
But, It doesn't respond the UIButtonMessage event..

« Last Edit: January 28, 2013, 07:38:05 AM by kaywoods »

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: OnClick, OnPress don't work on my iPad..
« Reply #1 on: January 28, 2013, 07:40:52 AM »
Make sure that the colliders are actually in the right spot on the iPad device. If it's a retina ipad, it may have moved it oddly because of the high resolution.

kaywoods

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 12
    • View Profile
Re: OnClick, OnPress don't work on my iPad..
« Reply #2 on: January 28, 2013, 10:44:47 AM »
Well, my iPad is iPad2(1024 * 768), not retina display..
And..if collider has moved odd place, why the touch over event works normally???

I placed the Button widget, also with the tween transform and tween color script by default.
And I touched over the iPad, the tween(from,to) color and transform works normally..
But the only button event doesn't work...

I attached the UIButtonMessage.cs to the Button widget.
and allocated the
-  'Target' : UIButtonMessageGameObject,
-  FunctionName : OnClickBtnPause
- Trigger : OnClick


and the inside the script
void OnClickBtnPause(){
   Application.LoadLevel("MainLevel");
}

===> It works very well on the Unity Editor with the mouse click event...
But on the iOS device(my iPad2) through XCode compiling, it doesn't work the
OnClickBtnPause() ...
only works the tween color and transform to my finger touch...

I think it's so strange..

I am so embarrassed that I don't know what to debug....??
 

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: OnClick, OnPress don't work on my iPad..
« Reply #3 on: January 28, 2013, 02:34:25 PM »
2.2.3 is old, I can't support it. The latest is 2.3.1.

Majicpanda

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 83
    • View Profile
Re: OnClick, OnPress don't work on my iPad..
« Reply #4 on: January 28, 2013, 06:02:00 PM »
I just did my very first project ever and used nGUI from scratch and can confirm the latest worked flawlessly for MAC, PC, iPhone 4/5 and my iPad Retina... have not tested on iPad 2 though.

Unless you've modified nGUI.... not sure how much would break.  You've got versioning right? If not.. just save the whole project somewhere and test ;)  I know for sure the latest works great across all iOS devices with Unity 4.

kaywoods

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 12
    • View Profile
Re: OnClick, OnPress don't work on my iPad..- I found out the cause...
« Reply #5 on: January 29, 2013, 02:58:21 AM »
Well...
As I told, I upgraded the latest NGUI 2.3.1., but the result was the same.

All that I modified to the NGUI is that I moved some scripts to the Plugin folder to use NGUI with the Javascript..
(Interaction/Internal/Tweening/UI folders)

When the button widget created, such a script as
UIButton.cs,
UIButtonScale.cs,
UIButtonOffset.cs,
UIButtonSound.cs 
automatically also added...

I added the UIButtonMessage.cs this button widget,
and set the parameters like   
- target GameObject
- function name
- trigger : OnClick or OnPress..

And the result was that only the button event didn't work on the real iOS device, my iPad2(I mean the UIButtonMessage.cs),
all other functions(button scale/offset/sound..) works normally.
(But, in the Unity Editor everything works well including UIButtonMessage.cs)

So, I doubted that there's some problems in the UIButtonMessage.cs

I removed the UIButtonMessage.cs script and
used the my own custom script and used the OnPress(), instead of using function name method in the target GameObject as follows..

This is my custom script, attached the button widget..
...
void OnPress(bool isPressed){
   if(isPressed == true){
     Application.LoadLevel("MyLevel1");
  }
...

And this works...normally...

So I concluded the UIButtonMessage.cs has some problems on the iOS Platform...not Unity Editor,,or other platform...

Without using UIButtonMessage means that I have to create each script to every buttons...
If I have 10 different buttons, I have to create 10 scripts...oh my god..!!!


Maybe my conclusion will be wrong,,
but this conclusion is drawn by the my trial and error efforts..
So, correct it in the next version if my conclusion is right...



..from C# beginner and NGUI User...

« Last Edit: January 29, 2013, 03:46:06 AM by kaywoods »

Matt.Hartfield

  • Guest
Re: OnClick, OnPress don't work on my iPad..
« Reply #6 on: January 29, 2013, 01:47:37 PM »
I had this same issue and posted a bug about it.....

The issue is inconsistency in NGUI between PC and iOS dealing with clipping ray casts.
De-check to clip them and it should work on your iOS devices again.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: OnClick, OnPress don't work on my iPad..
« Reply #7 on: January 29, 2013, 05:28:57 PM »
Have you seen LoadLevelOnClick script that comes with NGUI?

In any case there is no reason to have 10 scripts. Expose a parameter -- a string for example, and set it in inspector.

...or just use LoadLevelOnClick.

kaywoods

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 12
    • View Profile
Re: OnClick, OnPress don't work on my iPad..
« Reply #8 on: January 29, 2013, 11:53:19 PM »
I had this same issue and posted a bug about it.....

The issue is inconsistency in NGUI between PC and iOS dealing with clipping ray casts.
De-check to clip them and it should work on your iOS devices again.


Hello Matt??

Do you mean by the parameter of UICamera, called "Clip Raycast"??
I unchecked the 'Clip raycast' parameter in the UICamer..but it doesn't work either.

Does this problem have any relation with the "Clipping" parameter in the UIPanel ????
« Last Edit: January 29, 2013, 11:54:51 PM by kaywoods »

kaywoods

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 12
    • View Profile
Re: OnClick, OnPress don't work on my iPad..
« Reply #9 on: January 30, 2013, 12:02:09 AM »
Have you seen LoadLevelOnClick script that comes with NGUI?

In any case there is no reason to have 10 scripts. Expose a parameter -- a string for example, and set it in inspector.

...or just use LoadLevelOnClick.


All the button's event isn't the loadlevel event.
Some of them is the load level, others isn't.


If the Matt.Hartfiled's comment  is right, which is the emergent quick method to prevent the error ?

I followed the Matt.Hartfield's comment, but the problem didn't solved...
I think there's some other things what I don't know...