Introduction to Unity5.3+easytouch4.3--easytouch and joystick controls

Source: Internet
Author: User

First, Easytouch plug-in introduction

This article summarizes, the current online can be very convenient to download to the EasyTouch4.3 version (amount ... You know what is very convenient, because some versions and versions still have a lot of changes, it is stated in this article that the version used is 4.3, but the general framework of the plugin will not change a lot, you can refer to. The ability to purchase genuine children's shoes can also go to the official website to support the EasyTouch.

The EasyTouch4.3 version has started to support Ugui, so the unity version below 4.6 will not be able to use this version easytouch, currently EasyTouch4.3 Pro test can be used in conjunction with the unity4.6~5.3 version.

The following is the 4.3 version of the plug-in package directory structure:

You can see that the Easytouch is divided into two major modules in this version

    • The first module, Easytouch, is a basic response event, such as tapping the screen and clicking on the object in the scene, which is very handy because it is similar to the Ett (easy Touch Trigger) and the Ugui event system.
    • The second module, Easytouchcontrol, is a pre-prepared controller collection system in some plugins and incorporates Unity's own UI system, such as Dpad,joystick,touchpad,button. Each module has a corresponding document and interface file, detailed questions can be referred to the official documents.


Second, EasyTouch joystick function Introduction

There are two types of joystick in the easy Touch controls control set:

    • Static: The joystick will appear in your preset location.
    • Dynamic: The joystick will appear where you touch the screen. You can also force the joystick to appear only in a certain range.

Each joystick control consists of two images, one as the background and one as the key. The size of the joystick control is related to the size of the background image (this size can be set by the width and height parameters).

Rocker controls each axis (x and Y axis) returns a parameter size range of -1~1, or you can set whether the corresponding axis is to be opened by parameter.


(1) How to create joystick

Right-click the hierarchy window and select Joystick under Easytouch controls.


ETC will automatically create a canvas and a EventSystem game object.

(2) Joystick Control Inspector Panel

Attribute Group Description:

      • Activated: Whether to activate this joystick control, even if this property is disable State joystick control is also visible.
      • Visible: Whether the joystick is displayed.
      • Use Fiexed Update: This property needs to be checked if the update frequency of the physical system is used.
      • Position&size: Sets the joystick type and position, size.
      • Axes Properties: Axis property settings.
      • Sprites: Set the picture of the joystick.
      • Move events, Touch events, down events, press events: In these four event panels, you can set the defined time in any system, using the same method as the Ugui/ngui event invocation, Drag the calling method that already exists in the project directly onto the control. Joystick,dpad,touchpad These kinds of controls are similar to the event response mechanism, it is easy to implement reuse and replacement.

(3) position&size attribute group

Type: Sets the stick type (static or dynamic).

Anchor: Anchor Point settings

No Return of the thumb: thunmb the picture to return to the original position after the finger leaves the screen

Background size: Background picture sizes.

Thumbe Size: Thumb button sizes (that is, the size of the image that the thumb drags).

RADIUS based on: Sets the radius size of the joystick control based on what axis is determined. This parameter is useful when you import a picture that is not a square.


about the settings for dynamic joystick:

Dynamic joystick needs to set the scope of its appearance, you can choose the following type as needed, if you choose User Defined you need to specify the scope of the activity.

about the settings for static joystick:

Anchor: Setting of the anchor point

Offset: Offsets from the relative anchor point

If you select User Defined, you will need to specify the scope of the activity yourself.

about the area settings:

Creating an area can be used to develop a dynamic and static range of activities for joystick controls.

Here's how to create it:

Area Control Inspector Panel Property Description:

Show at runtime: whether the project is running state to display the area control.

Preset: Some area areas of the preset, set in the Recttransform component if you need to set a specific range yourself.

(4) Axes Properties Property Group

Horizontal Zxis & Vertical axis: Sets whether the horizontal and vertical axes are available, and the input box that follows can enter the name of the axis, and the name must be unique throughout the scene.

Inverted axis: Flips the axial positive and negative values.

Dead Length: This value determines how far away from the center each axis is in an invalid area, that is, if each axis moves up a distance less than the maximum distance, the axis does not have a return value.

On/off Threshold: Turn off threshold (related to the Down trigger event, refer to the Down Events section below the article)

Speed: This value is directly used to manipulate the motion velocity of the object when the joystick is moved, which can be obtained via the Etcinput.getaxisspeed interface (refer to ETCINPUT_API For more information about the interface). PDF document).

Action on: Action Time Press (keep holding)/down (pressed for a moment) feedback occurs.

Direct Action to: Sets the object to be manipulated by the joystick (the game object containing the transform component).

Action: Select the effect you want to have on the action to object. (moving, rotating, exerting force ...) )。

Affected Axis: Action axis (x/y).

Enable inertia: Whether to activate the delay function.

Positive key: The key can be set to the same function as the square of the joystick corresponding to the axis (the horizontal axis is to the right and the vertical axis is above).

Negative key: You can set this button with the joystick corresponding to the axis negative direction (the horizontal axis is left, the vertical axis is below) has the same function.

(5) Sprites attribute group

Sets the background and thumb button icons to correspond to pictures and basic colors.

You can also set it directly to the image component that corresponds to the game object (the background and thumb images are two game objects in the scene, respectively).


(6) events attribute Group

    • How do I add an event?

Find the corresponding trigger method and click the plus sign.

After writing the specific method you want to trigger, hang the script under the game object, then drag the game object to the corresponding trigger method, and select the method below the corresponding class just written in the function.
    • Move Events

On Move Start (): triggered when the lever is first moved (the trigger time will be reset when returning to the 0-point position)

On Move (VECTOR2): The process of moving the stick or the rocker thumb key does not return to the origin will continue to trigger, the distance of the stick on each axis (value range of -1~1) as a method parameter passed in.

On move speed (VECTOR2): The process of moving the stick or the rocker thumb key does not return to the origin will continue to trigger, the stick Axisvalue * axissensitivity*time.deltatime on each axis as a method parameter passed in.

On Move End (): Triggers when the joystick thumb key returns to the origin or the user releases the joystick.

    • Touch Events

On Touch Start (): Triggered when the joystick is first touched

On Touch Up (): Triggers when the user releases the joystick (Stop Touch)

    • Down Events

On Off up (): Triggers when the user presses the joystick for the first time and moves upward (resets the function trigger condition when the rocker thumb key returns to the origin or joystick position within the corresponding Axis threshold value range)

On (): triggers when the user presses the joystick for the first time and moves to the right (resets the function trigger condition when the rocker thumb key returns to the origin or joystick position within the corresponding Axis threshold value range)

On Down (): Triggers when the user presses the joystick for the first time and moves downward (resets the function trigger condition when the rocker thumb key returns to the origin or joystick position within the corresponding Axis threshold value range)

On-left (): Triggers when the user presses the joystick for the first time and moves to the right (resets the function trigger condition when the joystick thumb returns to the origin or joystick position within the corresponding Axis threshold value range)

    • Press Events

On press Up (): triggered when the joystick is pressed and moved up

On press Right (): triggered when the joystick is pressed and moved

On press Down (): triggered when the joystick is pressed and moved down

On press Left (): triggered when the joystick is pressed and moved to the left


Third, a 2D small example of joystick control movement

(1) Import related Resources

Import the required resources and set the relevant parameters and drag them into the scene.

(2) Create a joystick

Right-hierarchy panel =>easy Touch controlls=>joystick or menu bar, click Gameobject menu =>easy Tou CH Controlls=>joystick

Adjust the joystick position, and set the joystick to control the object and control mode, the following parameters are set:


(3) Create a control script

Using unityengine;using System.collections;public class playermonitor:monobehaviour{public    void Joystickcontrolmove (Vector2 direction)    {        this.transform.rotation = quaternion.lookrotation (New Vector3 ( direction.x, DIRECTION.Y, 0));}    }

(4) Adding corresponding control method for joystick


(5) Final effect

Moving the joystick thumb button model will make a synchronous motion and change the orientation of the model during movement.


Introduction to Unity5.3+easytouch4.3--easytouch and joystick controls

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.