Author Topic: NGUI with Unity 2017.2 - raycast/collider issues when no Rigidbody present?  (Read 446 times)

BurningToad

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 9
    • View Profile
Hello!

I've encountered an issue that may be completely our own project's fault, but I haven't been able to figure it out.  We are working on upgrading from Unity 5.6 to Unity 2017.2 and in doing so, we have noticed our NGUI based UI has a strange issue.  When we resize the screen, or when UI elements get moved, their colliders don't seem to update properly.  They look fine in scene view, but raycasts don't hit them when they should, they instead hit where the colliders used to be before the element was moved or the screen was resized. 

As an example, say we have a UISlider with the thumb being a sprite with a collider on it.  Resize the screen, collider position doesn't seem to update for raycasts.  If I add a rigidbody to collider gameobject, it works just fine when resizing the screen.  It worked just fine in Unity 5.6 with no rigid body.  Any ideas about what could be causing this?  As another test, we removed all rigidbodies from UI (including UIPanels) and the UI still all worked just fine in 5.6.  In 2017.2 with no rigid bodies on panels, things were all kinds of haywire.  But unfortunately it now seems EVERY UI collider would need a rigid body to work properly....

I haven't been able to repro any issues with the base NGUI and example scenes provided in Unity 2017.2, so I guess it is likely an issue on our end.  We do have some custom changes to NGUI, but I can't think of any of them that would cause this issue. 

I guess I'm just wondering if anyone else has run into this, or if anyone has any ideas on what would cause this and how to fix it without adding a million rigidbodies to our UI.

BurningToad

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 9
    • View Profile
I just noticed the UICamera option "Events go to..." and ours is set to Rigidbodies.  When I tried changing this to Colliders, it seems to improve things a bit, I think?  However, the issue is still there even with that option, so it isn't a fix....

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 336
  • -Receive: 1160
  • Posts: 22,121
  • Toronto, Canada
    • View Profile
Is your game's time paused when you do this? IIRC colliders don't actually update until FixedUpdate() has a chance to run, and it doesn't run if the time is paused.

Other than that, it's quite possible that Unity broke something. They do that from time to time...

BurningToad

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 9
    • View Profile
I found out some more info after I tested and discovered that the issue occurs for us because we enable/disable colliders when showing/hiding dialogs in certain ways.  I found other people with the same problem:

https://issuetracker.unity3d.com/issues/colliders-are-not-updating-to-match-attached-gameobject-location

https://answers.unity.com/questions/1421546/capsule-collider-istrigger-problem-from-unity-56-t.html

So yes, Unity broke something.... again :(

BurningToad

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 9
    • View Profile

dafunker

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 7
    • View Profile
I have a similar problem in a UIScrollView populated with some draggable UIWidget (Collider, 3D).

Everything works in Editor.
Everything works on ~95% of Android Phones.

However, on ~5% (Galaxy S4 Mini by example), i have this particular flow :
- on press, drag the scroll list
- everything is moving fine
- on release, all the elements in list disappear.

I have debugged with ADB and there are some error message about raycast/collider issue.
I have tested the Unity 2017.2 p2 and Unity beta where it was supposed to fixed.. but no.

I have tried many things (Adding rigibody with kinematic, without, ...) but the issue still occurs on some Android devices.
Have you ever seen something like this ?

BurningToad

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 9
    • View Profile
The particular issue that I was having was reproducible in all cases, both in editor and client (PC.)  So, I'm sorry, but I'm not sure about your issue dafunker