(5) Joystick/Button/Touchpad

The functions in front of Each Touch are relatively easy to implement with Unity's own UI events, but its strongest point is that it encapsulates the operation of the first-person game on the mobile terminal. The following are several key functions:

(1) Joystick

Right-click -> select Easytouch controls-> select Joystick to add as shown below.

 

1)joystick name

This name is the same as the game name, but the name of the game object cannot be renamed. You can only modify the name here. The parameters after the joystick name are relatively useless.

2)position&size

This part is used to set the position and size. If the type is selected as dynamic, the button is hidden at the beginning and will appear dynamically at the clicked position. The second parameter anchor point, if user-defined is not selected, cannot be set in recttransform, but can only be set in joystick.

3)axes properties

This part is the key point of setting. If Turn & move direction action is selected, it means that it can be rotated. The game object that is used is the game object specified by the Direct action to parameter. You can also click the auto link on tag to determine the game object that is used by specifying the layer. . Turn & move direction action will affect the horizontal axis and vertical axis sub-parameters below. Uncheck it, but it is subject to the horizontal axis and vertical axis sub-parameters (emphasis).

Horizontal axis (vertical axis): These parameters are used to set the impact of related operations on game objects, and subsequent event (parameter moveevent, etc.) binding functions can achieve similar functions (that is, manually write control codes in the bound events). This is equivalent to quickly realizing the function through parameter definition. The name behind it can be modified, and the parameters in the horizontal direction can be obtained through this name (similar to the Input.GetAxis("Horizontal") function); ETCInput.GetAxisDownRight( " Horizontal " ) means to obtain the horizontal axis value named Horizontal (due to There can be different joysticks, so there will be different Horizontal axes, which are distinguished by name)

                General setting: It is mainly the react on parameter and the speed parameter. The former is used to determine whether to press the trigger (trigger once) or to trigger continuously after pressing (continuous trigger), and the latter determines the speed of the movement.

                Direction action: Indicates the relevant motion control. The game object specified by the Direct action to parameter can also be clicked on the auto link on tag to determine the role of the game object by specifying the layer. action indicates the motion form (rotation or moved or jump...), affected axis indicates the motion axis, and some do not have this option, for example, the action parameter value is jump.

                Gravity-inertia-smoothing: Set the relevant inertia, that is, whether to stop the movement immediately after releasing the button or inertia for a period of time.

                Unity axis: Whether the axis in the input class corresponding to unity corresponds to (such as vertical, horizontal, etc.), if the first option of the axes properties Enable unity axis is not checked, this option has no effect.

4)camera

Enable tracking: Whether to enable tracking, that is, whether there is a moving object perspective (whether the camera tracks the game object). So you need to set the tracking camera and the corresponding game object

5)sprites

button map

6)MoveEvent~PressEvent

The related events, like the button operation method, can also be implemented by the ETCInput class due to the large number of events. See the code at the end of the article.

 

(2) D-pad, TouchPad

Right-click -> select Easytouch controls-> select D-pad to add, its parameters are basically similar to Joystick, so I won't go into details.

The TouchPad functions similarly to the Joystick, but in the form of a touchpad.

(3) Button

Right-click -> select Easytouch controls-> select Button to add. Its function is less than the above three categories, it is equivalent to the extension of the unity Button function, and can quickly define the movement form related to the movement when clicking through the Direction action parameter (all four buttons have this parameter, the function is the same). And get the current value through ETCInput.GetButtonValue( "Button") (the test is all 1, I don't know what special meaning)

 

 

Button code event    


    if (ETCInput.GetButton("Button")){
            getButtonText.text="YES";
            getButtonTimeText.text = ETCInput.GetButtonValue( "Button").ToString();           
        }
        else{
            getButtonText.text="";
            getButtonTimeText.text = "";
        }

        if (ETCInput.GetButtonDown("Button"))
        {
            getButtonDownText.text = "YES";
            StartCoroutine( ClearText(getButtonDownText));

        }

        if (ETCInput.GetButtonUp("Button")){
            getButtonUpText.text = "YES";
            StartCoroutine( ClearText(getButtonUpText));
        }

 

 

code control event       



 ETCInput.GetAxis( " Horizontal " ); // Get the return value of the horizontal axis (same as Unity's Input.GetAxis); 
        ETCInput.GetAxisSpeed( " Horizontal " ); // Get the movement speed of the horizontal axis; 
        ETCInput.GetAxis( " Vertical " );
        ETCInput.GetAxisSpeed("Vertical");

        // Press and release (execute only once) 
        if (ETCInput.GetAxisDownRight( " Horizontal " )){
            downRightText.text = "YES";
            StartCoroutine( ClearText(downRightText));
        }

        if (ETCInput.GetAxisDownDown("Vertical")){
            downDownText.text = "YES";
            StartCoroutine( ClearText(downDownText));
        }

        if (ETCInput.GetAxisDownLeft("Horizontal")){
            downLeftText.text = "YES";
            StartCoroutine( ClearText(downLeftText));
        }

        if (ETCInput.GetAxisDownUp("Vertical")){
            downUpText.text = "YES";
            StartCoroutine( ClearText(downUpText));
        }

        // Continuously press and release (continuous execution) 
        if (ETCInput.GetAxisPressedRight( " Horizontal " )){
            rightText.text ="YES";
        }
        else{
            rightText.text ="";
        }

        if (ETCInput.GetAxisPressedDown("Vertical")){
            downText.text ="YES";
        }
        else{
            downText.text ="";
        }

        if (ETCInput.GetAxisPressedLeft("Horizontal")){
            leftText.text ="Yes";
        }
        else{
            leftText.text ="";
        }

        if (ETCInput.GetAxisPressedUp("Vertical")){
            upText.text ="YES";
        }
        else{
            upText.text ="";
        }



 

Event registration time    



public void MoveStart(){

    }

    public void Move(Vector2 move){

    }

    public void MoveSpeed(Vector2 move){

    }

    public void MoveEnd(){

    }

    public void TouchStart(){

    }

    public void TouchUp(){

    }

    public void DownRight(){

    }

    public void DownDown(){

    }

    public void DownLeft(){

    }

    public void DownUp(){

    }

    public void Right(){

    }

    public void Down(){

    }

    public void Left(){

    }

    public void Up(){

    }

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325017905&siteId=291194637