Performing UI events blocking Ray scene events

Source: Internet
Author: User

When the mouse clicks the Ngui UI in unity, the Rays collide with the scene object, performing other manifestations.

So the question is how to avoid simultaneous triggering,

One principle is that the UI executes the first order.

So let's talk about the main thread execution sequence.

1. Main thread structure

  

 1  public  class   Gamemain:monobehaviour  2   { 3  void   Update ()  4   { 5   NGUIManager.Instance.Update ();  6   GameSceneManager.Instance.Update (); 7   ....  8   9
     } 

2, above can see UI execution priority higher than other logic, we look at the UI logic

public bool Raycasthitui (Vector3 positon) {Vector3 pos = camera.screentoviewportpoint (Positon); if (Pos.x < 0f | | Pos.x & Gt 1f | | Pos.y < 0f | | Pos.y > 1f) return false; Ray Ray = Ui2dcamera.screenpointtoray (inPos), int mask = 1 << 20;float dist = (uicamera.rangedistance > 0f)? Uicamera.rangedistance:ui2dcamera.farclipplane-ui2dcamera.nearclipplane;if (Physics.raycast (Ray, out UiHit, Dist, Mask) return True;return false;}

  

So the UI event is executed and the logic behind it is not executed!

Performing UI events blocking Ray scene events

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.