Unity EasyTouch(一)

导入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 axesunity 轴
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");
		}
	}
}

 

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
EasyTouch是一个在Unity中使用的触摸输入插件。在使用EasyTouch之前,你需要在场景中创建一个EasyTouch物体,并在其上添加EasyTouch脚本。如果你使用的是EasyTouch四代,还需要创建一个名为EasyTouchManager的GameObject,并将EasyTouchManager4_Demo.cs脚本附加到EasyTouchManager上。\[1\] 你可以从百度云上下载EasyTouch插件,并将其导入到Unity项目中。请注意,这个插件仅供学习使用,如果你需要商业使用,请去官网购买正版。\[2\] 在使用EasyTouch时,你可以通过注册和监听事件来响应触摸输入。例如,你可以创建一个名为TouchTest的脚本,并在其中订阅On_TouchStart事件。当手指接触屏幕时,On_MyTouchStart方法将被执行,并打印出触摸到屏幕的坐标。记得在适当的时候取消订阅事件,以避免内存泄漏。\[3\] 希望这些信息对你有帮助!如果你还有其他问题,请随时提问。 #### 引用[.reference_title] - *1* *2* [Unity- EasyTouch(一)](https://blog.csdn.net/qq_40985921/article/details/88734354)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item] - *3* [Unity3d插件 之 Easytouch](https://blog.csdn.net/mengyin521/article/details/50706323)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值