Learning the easytouch plug-in

Source: Internet
Author: User

First of all, this plug-in is a plug-in that implements the virtual joystick,


First, there is an easy button. Here we will talk about two of its events. The other methods like how to obtain components are similar to ngui and ugui. The easy button has two events, they are massage and event. Here we mainly talk about event. event is a delegate in C #. What is a delegate? You can read the C # book.


Here we write a script,


Using unityengine;

Using system. collections;

Public class eventtext: monobehaviour {

Void onenabled ()

{

Easybutton. on_buttondown + = downmethod;

}

Void ondisable ()

{

Easybutton. on_buttondown + = downmethod;

}

Void downmethod (string btnname)

{

Print (btnname + "down ");

Debug. logs ("111 ");

}

}


This is a button event.


Then let's talk about how the virtual joystick gets events.


The Code is as follows:


Using unityengine;

Using system. collections;

Public class joystick: monobehaviour {

Public easyjoystick joystick1;

Void Update ()

{

Print (joystick1.joystickaxis );

}

}


Then let's talk about touch.


Using unityengine;

Using system. collections;

Public class easytouchtext: monobehaviour {

Void on_touchstart (gesture g) // trigger events by name

{

Debug. Log ("touchstart" + G. position );

}

}

The above is through listening,


Then, let's write a method for listening to trigger events through scripts.


// Register

Void start ()

{

Easytouch. on_touchstart + = This. on_touchstart;

}

Void on_touchstart (gesture g) // trigger events by name

{

Debug. Log ("touchstart" + G. position );

}

}

Remember, here we need to remove the check mark before broadcast messages.


Then we will write another event, which can be triggered only by clicking a specific location, such as a specific button,


Here we create a cube, and then we create a script to write the following code,

Void on_touchstart (gesture g) // trigger events by name

{

Debug. Log ("touchstart" + G. position );

}


Create a layer in U3D and define it as guicamera.

Set the layer of our cube to guicamera and set easy touch.




This article is from the "computer" blog, please be sure to keep this source http://5152481.blog.51cto.com/5142481/1602259

Learning the easytouch plug-in

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.