Upgrade to Pro — share decks privately, control downloads, hide ads and more …

InputSystemことはじめ

Avatar for Naoya Kurihara Naoya Kurihara
December 15, 2018
1.5k

 InputSystemことはじめ

Unity お・と・な のLT大会 2018
InputSystemについてのLT
プレビュー機能についてのスライドなので最新の情報から差異がある場合があるのでご注意を。

Avatar for Naoya Kurihara

Naoya Kurihara

December 15, 2018
Tweet

Transcript

  1. 導入 "com.unity.modules.xr":"1.0.0", "com.unity.inputsystem":"0.0.13-preview"  // <= 追加 }, "registry": "https://staging-packages.unity.com" //

    <= satging のレジストリを指定するため追加 } Packageのmanifest.jsonを書き換え
  2. アクションイベント public class InputAction : ICloneable { … public event

    Action<CallbackContext> performed; public event Action<CallbackContext> started; public event Action<CallbackContext> cancelled;
  3. アクションイベント public void Awake() { controls.player.move.performed += ctx => m_Move

    = ctx.ReadValue<Vector2>(); controls.player.jump.performed += ctx => { if (ctx.interaction is SlowTapInteraction) {
  4. マルチ実装 actionMap = controls.player.Clone(); InputSystem.onDeviceChange += (device, change) => {

    switch (change) { case InputDeviceChange.Added: { switch(allowDeviceType) { if (device is Gamepad) { actionMap.devices = new InputDevice[] { device };