// ==============================
// Unity 新输入系统 Input System 完整笔记 + 代码
// 结构:ActionMaps → Actions → ActionProperties
// 包含:Button事件绑定 / Value值获取
// ==============================
/*
一、核心概念
- ActionMaps:行为映射图集(分组:Player/UI等)
- Actions:行为分类(Jump/Move/Fire等)
- ActionProperties:按键类型(Button/Value)
二、使用步骤
- 右键 → Input Actions → 创建 PlayerInputActions
配置:
- ActionMap: Player
- Jump → Button → 绑定 Space
- Move → Value → Vector2 → 绑定 WASD/摇杆
- 勾选 Generate C# Class → Apply 自动生成脚本
*/
using UnityEngine;
using UnityEngine.InputSystem;
public class PlayerInputController : MonoBehaviour
{
// 自动生成的输入系统类
private PlayerInputActions _inputActions;
private void Awake()
{
// 生成新输入系统类实例
_inputActions = new PlayerInputActions();
}
private void OnEnable()
{
// 启用 ActionMap
_inputActions.Player.Enable();
// ==============================
// Button 类型:事件绑定方式
// ==============================
_inputActions.Player.Jump.started += OnJumpStarted;
_inputActions.Player.Jump.performed += OnJumpPerformed;
_inputActions.Player.Jump.canceled += OnJumpCanceled;
}
private void OnDisable()
{
// 注销事件
_inputActions.Player.Jump.started -= OnJumpStarted;
_inputActions.Player.Jump.performed -= OnJumpPerformed;
_inputActions.Player.Jump.canceled -= OnJumpCanceled;
// 禁用 ActionMap
_inputActions.Player.Disable();
}
private void Update()
{
// ==============================
// Value 类型:值获取方式
// ==============================
Vector2 moveInput = _inputActions.Player.Move.ReadValue<Vector2>();
}
// Button 回调
private void OnJumpStarted(InputAction.CallbackContext ctx) => Debug.Log("跳跃按住中");
private void OnJumpPerformed(InputAction.CallbackContext ctx) => Debug.Log("跳跃按下");
private void OnJumpCanceled(InputAction.CallbackContext ctx) => Debug.Log("跳跃松开");}
// ==============================
// 核心语法总结
// 1. 生成输入类:new PlayerInputActions()
// 2. Button绑定:动作.started/performed/canceled += 方法
// 3. Value获取:ReadValue
// ==============================
Solid perspective. Modern adult platforms feel very distinct from old-school ones
Good perspective. Some 18+ video websites clearly focus on user comfort now
Nice read. I’ve seen the same improvements on several 18+ video platforms
Good insights here. Presentation definitely impacts how long users stay on adult platforms
Good article — it actually lines up with what I’ve seen on some newer 18+ video platforms lately
Thanks for the post. Clean design really separates quality adult platforms from the rest
This article makes sense. Simple layouts really enhance the experience on 18+ platforms