Block clicks on the 3D scene when Unity pops up the interface

Source: Internet
Author: User

Note: The UI system here is the Ngui plugin

Title, in the game often encounter this situation, the scene click on the relevant object or button to pop up the corresponding 2D interface, this time in addition to the 2D interface clickable button, etc., should be shielded from the 3D scene of the click or drag events.

Here are two ways of doing this:

1. Add a large enough collider to the 2D interface to cover the entire screen:

// Add a collider to the Corridor Information Panel to mask the mouse click event gameobject.addcomponent<boxcollider> () on the 3D scene when the popup panel is blocked ; Gameobject.getcomponentNew Vector3 (24000);

The way you add components directly in unity without code additions may cause the collider to overwrite buttons on the Ngui interface causing the button to not click, and you should also be aware of the location of the code where the collider is added, or it may cause the problem;

When two interfaces overlap in the Ngui, the response is that of the larger collider interface;

2. When the click and drag events in the scene are implemented with the Fingergestures plugin, the fingergestures script can be invalidated:

Gameobject.find ("fingergestures"false;

When the 2D interface is turned off, the script takes effect:

Gameobject.find ("fingergestures"true;

Block clicks on the 3D scene when Unity pops up the interface

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.