Author Topic: BUG about "clipRaycasts" in the UICamera.  (Read 4223 times)

zhing

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 7
    • View Profile
BUG about "clipRaycasts" in the UICamera.
« on: December 17, 2012, 09:39:00 AM »
I have try to use UICamera.clipRaycasts with a button in the clip UIPanel. But "clipRaycasts" isn't work.

After debug into the UICamera. I found that line 454.
  1. if (Physics.Raycast(ray, out hit, dist, mask)) return true;
  2.  
at the end of the function "static public bool Raycast (Vector3 inPos, ref RaycastHit hit)" is unnecessary.

Because it override the result by "clipRaycasts" checked.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: BUG about "clipRaycasts" in the UICamera.
« Reply #1 on: December 17, 2012, 10:04:01 AM »
Try adding "return false;" at the end of the "if (cam.clipRaycasts)" section like so:
  1. ...
  2. else if (hits.Length == 1 && IsVisible(ref hits[0]))
  3. {
  4.         hit = hits[0];
  5.         return true;
  6. }
  7. return false;

zhing

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 7
    • View Profile
Re: BUG about "clipRaycasts" in the UICamera.
« Reply #2 on: December 17, 2012, 10:12:25 AM »
I have changed the code to:
  1. 430:            if (cam.clipRaycasts)
  2. 431:            {
  3. 432:                    RaycastHit[] hits = Physics.RaycastAll(ray, dist, mask);
  4. 433:
  5. 434:                    if (hits.Length > 1)
  6. 435:                    {
  7. 436:                            System.Array.Sort(hits, delegate(RaycastHit r1, RaycastHit r2) { return r1.distance.CompareTo(r2.distance); });
  8. 437:
  9. 438:                            for (int b = 0, bmax = hits.Length; b < bmax; ++b)
  10. 439:                            {
  11. 440:                                    if (IsVisible(ref hits[b]))
  12. 441:                                    {
  13. 442:                                            hit = hits[b];
  14. 443:                                            return true;
  15. 444:                                    }
  16. 445:                            }
  17. 446:                    }
  18. 447:                    else if (hits.Length == 1 && IsVisible(ref hits[0]))
  19. 448:                    {
  20. 449:                            hit = hits[0];
  21. 450:                            return true;
  22. 451:                    }
  23. 452:                    return false;
  24. 453:            }
  25. 454:            else if (Physics.Raycast(ray, out hit, dist, mask)) return true;
  26.  
I think maybe it was the right way. :D