回答編集履歴
4
修正
test
CHANGED
@@ -40,7 +40,7 @@
|
|
40
40
|
### InputInteraction
|
41
41
|
|
42
42
|
長押しやダブルクリックなどそういうのをInteractionsで指定するみたいですね。
|
43
|
-
デフォルトでも何個か用意されているみたいです。下記
|
43
|
+
デフォルトでも何個か用意されているみたいです。下記みたいなやつです。
|
44
44
|
|
45
45
|

|
46
46
|
|
3
InputInteraction
test
CHANGED
@@ -36,3 +36,53 @@
|
|
36
36
|
}
|
37
37
|
```
|
38
38
|
[参考](https://ufcpp.net/study/csharp/sp_event.html#event-keyword)
|
39
|
+
|
40
|
+
### InputInteraction
|
41
|
+
|
42
|
+
長押しやダブルクリックなどそういうのをInteractionsで指定するみたいですね。
|
43
|
+
デフォルトでも何個か用意されているみたいです。下記はタップの閾値を変えるやつ
|
44
|
+
|
45
|
+

|
46
|
+
|
47
|
+
これを自作したい時に、`IInputInteraction`を実装して初期化するとInteractionsで選択できるようになるみたいです。
|
48
|
+
|
49
|
+

|
50
|
+
|
51
|
+
何も実装されていない最小コードが下記です。
|
52
|
+
|
53
|
+
```c#
|
54
|
+
using UnityEngine;
|
55
|
+
using UnityEngine.InputSystem;
|
56
|
+
|
57
|
+
#if UNITY_EDITOR
|
58
|
+
using UnityEditor;
|
59
|
+
[InitializeOnLoad]
|
60
|
+
#endif
|
61
|
+
public class InputInteractionTest : IInputInteraction
|
62
|
+
{
|
63
|
+
public void Process(ref InputInteractionContext context)
|
64
|
+
{
|
65
|
+
// ここに自作したい内容を記述
|
66
|
+
}
|
67
|
+
|
68
|
+
public void Reset()
|
69
|
+
{
|
70
|
+
|
71
|
+
}
|
72
|
+
|
73
|
+
// 初期化 ----------
|
74
|
+
#if UNITY_EDITOR
|
75
|
+
static InputInteractionTest()
|
76
|
+
{
|
77
|
+
Initialize();
|
78
|
+
}
|
79
|
+
#endif
|
80
|
+
|
81
|
+
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
|
82
|
+
static void Initialize()
|
83
|
+
{
|
84
|
+
InputSystem.RegisterInteraction<InputInteractionTest>();
|
85
|
+
}
|
86
|
+
}
|
87
|
+
```
|
88
|
+
|
2
修正
test
CHANGED
@@ -15,7 +15,7 @@
|
|
15
15
|
[参考](https://docs.unity3d.com/Packages/com.unity.inputsystem@1.3/api/UnityEngine.InputSystem.InputActionPhase.html)
|
16
16
|
|
17
17
|
### +=
|
18
|
-
|
18
|
+
どこに書いてるか分からないので予想ですが、下記のように実装すると`InputActionPhase.Canceled`のタイミングで`OnCanceled(InputAction.CallbackContext obj)`が呼ばれます。
|
19
19
|
|
20
20
|
```c#
|
21
21
|
moveAction = actionMap["Move"];
|
1
修正
test
CHANGED
@@ -15,6 +15,7 @@
|
|
15
15
|
[参考](https://docs.unity3d.com/Packages/com.unity.inputsystem@1.3/api/UnityEngine.InputSystem.InputActionPhase.html)
|
16
16
|
|
17
17
|
### +=
|
18
|
+
+= しまくったり、+= した後にオブジェクトを削除したりして遊んでみてください。
|
18
19
|
|
19
20
|
```c#
|
20
21
|
moveAction = actionMap["Move"];
|
@@ -34,3 +35,4 @@
|
|
34
35
|
moveAction.canceled -= OnCanceled;
|
35
36
|
}
|
36
37
|
```
|
38
|
+
[参考](https://ufcpp.net/study/csharp/sp_event.html#event-keyword)
|