Unity-easytouch plug-in Reservedarea application (mainly to avoid the contradiction between joystick and touch)

Source: Internet
Author: User

Yesterday, someone asked me, Easytouch plug-in has a small bug, in fact, is not a bug, plug-in designers have long considered such a situation.

He said that simultaneous use of Easyjoystick and Easytouch will occur, when the lever is moved, touch will also trigger, that is, both produce events.

So, what to do with it. The designer had long known that this would happen, so he applied Reservedarea (reserved area).

What it means is that joystick is a rocker, so there must be an area that triggers things.

Then the area of the triggering event will be added to the reserved area.

I accidentally entered the source of the Easyjoystick, found that: verified I said before.

So, when we want to move the stick, it doesn't trigger touch, so we just have to say one sentence:

Using unityengine;using system.collections; #region Module Information/*-------------------------------------------------------- --------//Module name: touchrect//Creator: chen//modifier list://Created Date: #CREATIONDATE #//Module Description://--------------------------------------- -------------------------*/#endregionpublic class touchrect:monobehaviour{    void Onenable ()    {        Easytouch.on_touchstart + = Mytouchstart;    }    void Ondisable ()    {        unsubscribeevent ();    }    void OnDestroy ()    {        unsubscribeevent ();    }    void Unsubscribeevent ()    {        Easytouch.on_touchstart-= Mytouchstart;    }    private void Mytouchstart (Gesture Gesture)    {        if (Gesture.ishoverreservedarea)//Determine if the finger is inside the retention area, The previous joystick will be added to the reserved area as soon as it is activated.                                           //So, we just return it in this reserved area and don't do anything.        {            return;        }        Then your touch function realizes        //...    }   

OK, in fact, there is a way, is to determine whether a finger in a rect, here is more troublesome, because the joystick area is adapted to the screen, so he

Rect changes as the resolution changes, so does our rect when the resolution changes. So not advisable, but as long as you take the Easyjoystick source

Inside the variable arearect, can also be achieved. I don't speak much here.

The use of gesture.isinrect and Easytouch.isrectundertouch are desirable.

Unity-easytouch plug-in Reservedarea application (mainly to avoid the contradiction between joystick and touch)

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.