导入EasyTouch插件
我用的版本:
创建Joystick摇杆
Hierarchy视图中右击 ---> EasyTouch Controls ---> Joystick
创建后,会自动创建InputManager。
重命名:
不能通过F2或单击两次更改,允许在这两个位置更改:
更改后
更多属性:
ETC Joystick | ||
Activated | 是否激活 | |
Visible | 是否可见 | |
Use Fixed Update | 是否使用某些物理更新效果 | |
Unregister at disabling time | 禁用时是否进行事件检测 | |
Position & Size 位置与大小 | ||
Type | 类型 | |
Static | 静态 | |
Anchor | 锚点/位置(Use Defined用户自定义,可以通过Alt+Shift控制调整位置) | |
Offset | 偏移(用于位置调整) | |
No offset thumb | 只允许对thumb(摇杆小球)拖拽,点击摇杆底图/背景无效,不实现自动偏移 | |
No return of the thumb | 拖拽后不恢复 | |
Dynamic | 动态 | |
Allow over touchpad | 允许使用触摸板(创建:Hierarchy视图中右击---> EasyTouch Controls --->TouchPad) | |
Joystick area | 动态状态下的活动区域(自定义状态下,创建Joystick area作为活动区域) | |
Background Size | 背景大小 | |
Tnumb size | 中心球大小 | |
Radius based on | 半径 | Width基于宽度 Height基于高度 Use Defined用户自定义半径 |
Axes properties 轴属性 | ||
Enable Unity axes | 是否使用Unity的轴(Edit ---> Project Settings ---> Input) | |
Allow Unity axes on standalone | 允许独立使用Unity轴 | |
Force visible | ||
Turn & Move direction Action | 转向和移动方向 | |
Auto link on tag | 自动关联标签对应的物体 | |
Direct action to | 直接作用到的关联物体 | |
Move curve | 移动曲线 | |
Move speed | 移动速度 | |
Intial rotation | 初始旋转 | |
Lock in Jump | 锁定跳跃 | |
Gravity | 重力 | |
Horizontal axis | 横轴 | |
General setting | 一般设置 | |
React on | 起作用方式 | |
Press | 按住(持续) | |
Down | 按下(不持续) | |
Dead zone method | 死区方法(误操作) | |
Classical | 典型 | |
Curve | 曲线 | |
Dead length | 死亡长度(拖拽长度在这一范围内不起作用) | |
Inverted axis | 反转轴(操作与执行的轴相反) | |
On/Off Threshold | 开关阀值(超过此值后触发事件) | |
Speed | 速度 | |
Direction ation(optional) | 方向(可选) | |
Auto link on tag | 自动关联标签对应的物体 | |
Direct action to | 直接作用到的关联物体 | |
Action | 行为 | |
Affected axis | 影响轴 | |
Gravity-Inertia-smoothing… | 重力惯性平滑 | |
Enable inertia | 启用惯性 | |
Inertia | 惯性 | |
Threshold | 阀值 | |
Unity axes | unity 轴 | |
Vertical axis | 纵轴(同上) | |
Camera 相机 | ||
Enable tracking | 启用跟踪 | |
Auto link on tag | 根据标签关联物体 | |
Target mode | 目标模式 | |
Camera target | 相机目标 | |
Camera mode | 相机模式 | |
Follow | 跟随 | |
Offset | 偏移 | |
Smooth Follow | 平滑跟随 | |
Wall detection | 墙壁检测 | |
Wall Layer | 墙壁层 | |
Distance | 距离 | |
Height | 高度 | |
Height damping | 高度阻尼 | |
Rotation dampping | 旋转阻尼 | |
Sprites 图片/精灵 | ||
Background | 背景 | |
Thumb | 中心球 |
事件绑定
Move Events | 移动事件 |
On Move Start | 移动开始(摇杆开始活动时执行一次) |
On Move | 移动中(摇杆活动时一直执行,在On Move Start后面执行) |
On Move Speed | 移动速度(摇杆活动时一直执行,在On Move后面执行) |
On Move End | 移动结束(摇杆结束活动时执行一次) |
Touch Events | 触摸事件 |
On Touch Start | 开始触摸 |
On Touch Up | 停止触摸 |
Down Events | 按下时不同方向的事件 |
On Down Up | 向上时执行(一次) |
On Down Right | 向右时执行(一次) |
On Down Down | 向下时执行(一次) |
On Down Left | 向左时执行(一次) |
Press Events | 按住时不同方向的事件 |
On Press Up | 向上时执行(一直) |
On Press Right | 向右时执行(一直) |
On Press Down | 向下时执行(一直) |
On Press Left | 向左时执行(一直) |
代码执行事件
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ETCTest : MonoBehaviour
{
void Update()
{
Debug.Log("GetAxis_Horizontal:" + ETCInput.GetAxis("Horizontal"));
Debug.Log("GetAxisSpeed_Horizontal:" + ETCInput.GetAxisSpeed("Horizontal"));
Debug.Log("GetAxis_Horizontal:" + ETCInput.GetAxis("Vertical"));
Debug.Log("GetAxisSpeed_Horizontal:" + ETCInput.GetAxisSpeed("Vertical"));
if (ETCInput.GetAxisDownDown("Vertical"))
{
Debug.Log("GetAxisDownDown_Vertical");
}
if (ETCInput.GetAxisDownUp("Vertical"))
{
Debug.Log("GetAxisDownUp_Vertical");
}
if (ETCInput.GetAxisDownRight("Horizontal"))
{
Debug.Log("GetAxisDownRight_Horizontal");
}
if (ETCInput.GetAxisDownLeft("Horizontal"))
{
Debug.Log("GetAxisDownLeft_Horizontal");
}
if (ETCInput.GetAxisPressedDown("Vertical"))
{
Debug.Log("GetAxisPressedDown_Vertical");
}
if (ETCInput.GetAxisPressedUp("Vertical"))
{
Debug.Log("GetAxisPressedUp_Vertical");
}
if (ETCInput.GetAxisPressedRight("Horizontal"))
{
Debug.Log("GetAxisPressedRight_Horizontal");
}
if (ETCInput.GetAxisPressedLeft("Horizontal"))
{
Debug.Log("GetAxisPressedLeft_Horizontal");
}
}
}