using UnityEngine; using UnityEngine.InputSystem; public class TestingInputSystem : MonoBehaviour { private Rigidbody rigidbody; private PlayerInputActions inputActions; private void Awake() { rigidbody = GetCo
新输入系统主要有两种方式,一种是全局的InputActions直接用new获取 UIInputActions=newPlayerInputActions();UIInputActions.Enable();inputActions.Player.Attack.performed+=OnAttack; 另一种是在组件上挂载PlayerInpput,好处是可以区分不同玩家,精细的禁用单个行为,能自动处理设备断开连接,做本地多人的话也是刚需 但是...
1.在Package Manager窗口的Unity Registry下面找到New Input System点击安装即可,安装结束后会提示重启Unity以激活型输入系统 2.打开游戏场景选择玩家角色,我们来为它添加Player Input组件 3.新建一个输入配置文件,点击CreateActions 可以看到默认配置就够用了 4.设置 在Behaviour选项,选择Invoke Unity Events 这里的意思是...
该脚本文件中包含了ActionAsset资源的所有信息并为其每一个ActionMap都配置了相应的接口和Wrapper类,这也就表示开发者可以在代码中直接引用该类而无需理会ActionAsset资源,也就用不着PlayerInput组件了。 具体代码如下: //如果生成类的命名为MyControlsMyControls ctrl =newMyControls();//如果ActionAsset中配置了一个...
实际上,InputSystem为我们封装好了一个输入类,我们可以在玩家(或者其他的)身上挂载PlayerInput类,通过绑定事件来实现玩家输入。这样的用法更像UE的(蓝图方面)输入系统了,我们也要创建一系列Action映射来保证运行。点击Player Input组件上的Create Actions,选择文件夹就能创建完毕了。 在Input Action Asset中,我们可以对绑...
首先,需要告知引擎使用特定输入系统,选择Both可实现新旧系统兼容。若支持设备一栏为空,意味着兼容所有设备。为了查看官方案例,可从PackagesManager下载相应内容。使用新输入系统时,步骤如下:创建输入控制器、设置ActionMaps和Actions、添加PlayerInput组件、编写脚本绑定事件、测试事件响应。测试时发现按下space...
1.首先,在packmanager里面安装input system 画红线的地方是unity官方的一个demo案例 2.注意player setting这边的设置 自行调整使用那种输入系统 3.项目工程里,右键Create->Input Actions 编辑 左上角那个东西是一个控制单,比如因为有键盘手柄,所以建立2份控制单 ...
将脚本挂载上去,在PlayerInput中的Events时间中绑定该方法。 using UnityEngine; public class TestingInputSystem : MonoBehaviour { private Rigidbody rigidbody; private void Awake() { rigidbody = GetComponent<Rigidbody>(); } public void Jump()
//场景中的PlayerInput绑定监听 var eventData = data as EventDataPlayerMove; moveInput= eventData.position; //传递移动时的XZ方向的位置 }); } void FixedUpdate() { //删除: //moveInput = new Vector2(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical")); //坐标数据不再由Input.GetAxis获得...
关键配置:包括自定义的输入动作、默认选择的控制方案以及默认的行为映射方案。UIInputModule:用于新版控制UI,需要修改原系统以避免报错。无缝对接:相机关联、行为通知等设置确保输入系统与游戏逻辑无缝对接。PlayerInputBehavior选项:行为选项:提供SendMessages、BroadcastMessages、Invoke UnityEvent Actions和...