Skip to content

Commit 2495f5c

Browse files
committed
Addressed review feedback and replaced main example.
1 parent b1756b6 commit 2495f5c

File tree

1 file changed

+39
-11
lines changed
  • Packages/com.unity.inputsystem/InputSystem/Plugins/EnhancedTouch

1 file changed

+39
-11
lines changed

Packages/com.unity.inputsystem/InputSystem/Plugins/EnhancedTouch/Touch.cs

Lines changed: 39 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,19 +35,47 @@ namespace UnityEngine.InputSystem.EnhancedTouch
3535
/// </remarks>
3636
/// <example>
3737
/// <code>
38-
/// void Awake()
39-
/// {
40-
/// // Enable EnhancedTouch.
41-
/// EnhancedTouchSupport.Enable();
42-
/// }
38+
/// using UnityEngine;
39+
/// using UnityEngine.InputSystem.EnhancedTouch;
4340
///
44-
/// void Update()
41+
/// // Alias EnhancedTouch.Touch to "Touch" for less typing.
42+
/// using Touch = UnityEngine.InputSystem.EnhancedTouch.Touch;
43+
/// using TouchPhase = UnityEngine.InputSystem.TouchPhase;
44+
///
45+
/// public class Example : MonoBehaviour
4546
/// {
46-
/// foreach (var touch in Touch.activeTouches)
47-
/// if (touch.began)
48-
/// Debug.Log($"Touch {touch} started this frame");
49-
/// else if (touch.ended)
50-
/// Debug.Log($"Touch {touch} ended this frame");
47+
/// void Awake()
48+
/// {
49+
/// // Note that enhanced touch support needs to be explicitly enabled.
50+
/// EnhancedTouchSupport.Enable();
51+
/// }
52+
///
53+
/// void Update()
54+
/// {
55+
/// // Illustrates how to examine all active touches once per frame and show their last recorded position
56+
/// // in the associated screen-space.
57+
/// foreach (var touch in Touch.activeTouches)
58+
/// {
59+
/// switch (touch.phase)
60+
/// {
61+
/// case TouchPhase.Began:
62+
/// Debug.Log($"Frame {Time.frameCount}: Touch {touch} started this frame at ({touch.screenPosition.x}, {touch.screenPosition.y})");
63+
/// break;
64+
/// case TouchPhase.Ended:
65+
/// Debug.Log($"Frame {Time.frameCount}:Touch {touch} ended this frame at ({touch.screenPosition.x}, {touch.screenPosition.y})");
66+
/// break;
67+
/// case TouchPhase.Moved:
68+
/// Debug.Log($"Frame {Time.frameCount}: Touch {touch} moved this frame to ({touch.screenPosition.x}, {touch.screenPosition.y})");
69+
/// break;
70+
/// case TouchPhase.Canceled:
71+
/// Debug.Log($"Frame {Time.frameCount}: Touch {touch} was canceled this frame");
72+
/// break;
73+
/// case TouchPhase.Stationary:
74+
/// Debug.Log($"Frame {Time.frameCount}: ouch {touch} was not updated this frame");
75+
/// break;
76+
/// }
77+
/// }
78+
/// }
5179
/// }
5280
/// </code>
5381
/// </example>

0 commit comments

Comments
 (0)