Tasharen Entertainment Forum
Support => NGUI 3 Support => Topic started by: niall on August 12, 2014, 11:09:37 AM
-
I'm working on a book library app, for now the first scene is a bookshelf filled with a grid of book covers that are UI2DSprite with colliders and a script attached to process OnClick. That works fine, clicking/tapping a book is no problem, then it loads a new scene to display the book itself. More UI2DSprites are created using downloaded images from Application.persistentDataPath. These sprites also have a collider and another script attached to process OnClick. There are also some NGUI buttons for page forward/back/exit. This part works fine in Editor only, but on an iOS devices, no input is processed.
So I discovered the NGUIDebug.DrawBounds function that will draw the bounds of my colliders, just to ensure they exist. That doesn't seem to work on iOS, ok fine. So I just Debug.Log'd the bounds, and the colliders are there, in the correct locations, but still not processing the OnClick method. Well, maybe it's actually just locked up for whatever reason? These sprites are technically animations that I process when tapped, but since they aren't animating, I suppose it could just be locked...
So I added this Console script to my camera, it uses OnGUI methods, and isn't even related to NGUI at all, other than being attached to the same camera, I suppose...
http://pastebin.com/NrFpiRDB
That console displays a log window and an FPS display with a couple buttons to toggle each. The console and the buttons work fine, in both scenes, in the editor! On device, it works fine in the first scene, but when the book is loaded, I can only enable/disable the console itself (via 5-finger-touch), but I can't tap the toggle buttons at all. So the app isn't locked, it's processing my 5-finger-touch input on device, but other OnGUI input, and all NGUI input is not getting through, again only on device.
I am surely missing something completely trivial, but the past few hours of attempts have yielded no results. :(
NGUI version 3.6.9
edit: I should add that touch input is indeed enabled on the UICamera in both scenes. Also all gameobjects that exist in scene, even those created at runtime, are on the NGUI layer. At least they are in the editor, where I can see that. :)
-
Can you try replacing your 2D colliders with 3D instead? (NGUI -> Extras -> Switch to 3D Colliders)
I vaguely remember some reporting some issues with touch detection on 2D colliders in some situations.
-
They were actually already using 3D colliders. Since it was at least something to try, I changed them to 2D colliders, and they would no longer receive mouse input in the editor either! This is perhaps an interesting hint, anyway!
edit/update: I tried throwing a little testing script in the second scene, as seen here:
http://www.tasharen.com/forum/index.php?topic=4683.0
So my UICamera touches and events are at least actually happening, but it's not hitting my colliders, it's hitting the "nothing"
Another possible caveat that I don't think I've mentioned... My app starts in portrait mode, for the bookshelf view. When a book is tapped, it loads a new scene and switches to landscape mode. Within the editor, I just keep the Game view in landscape for the most part and deal with the ugly library view in favour of seeing the books while I'm working on that part. The collider positions/sizes reported in the editor do correspond to what i'm getting as output on the device, so I don't THINK that's the problem, but maybe NGUI does something I don't know about when switching from portrait to landscape? I've tried doing the switch to landscape mode before the new scene load, after scene load, and before/after the sprites are actually created after the scene load, but other than the last one that really screws things up, none of those made a difference for my lack of input. :(
-
Oh, switching portrait to landscape manually? That's some bug in Unity. There were a few threads on this in the past. You need to update your version of Unity.
http://www.tasharen.com/forum/index.php?topic=10156.0
-
OH $%&^*, that's the exact version of Unity that i'm using! Man, I gotta start keeping things more up-to-date, I guess! Thanks so much for that, I hadn't even thought of upgrading...