Project-Wide Actions

Input System的project-wide actions功能讓你可以設定一個能夠在整個專案中使用的Action Asset,當Action Asset設為project-wide actions之後,那這個action就是個preloaded asset,也就是說當你的App啟動後就會載入,並且一直保持可用直到App關閉為止。

建立Project-Wide Actions Asset
  1. 找到 Edit > Project Settings > Input System Package 並按下 Create a new project-wide Action Asset
  2. 在專案中會建立一個名為InputSystem_Actions的Action Asset。
  3. 這個InputSystem_Actions中已經有一些預設的Action,像是MoveJump等,符合大部分遊戲,並預設綁定大部分裝置如鍵盤,滑鼠,遊戲搖桿,觸控螢幕,XR等
  4. 在程式碼中使用InputSystem.actions去找到Action
    1
    InputSystem.actions.FindAction("Move");

上一篇:安裝Input System

下一篇:使用Action Editor編輯Action

Reference: https://docs.unity3d.com/Packages/com.unity.inputsystem@1.8/manual/ProjectWideActions.html

評論