Class EnhancedTouchSupport
API to control enhanced touch facilities like Touch that are not enabled by default.
Namespace: UnityEngine.InputSystem.EnhancedTouch
Syntax
public static class EnhancedTouchSupport
Remarks
Enhanced touch support provides automatic finger tracking and touch history recording.
It is an API designed for polling, i.e. for querying touch state directly in methods
such as MonoBehaviour.Update
. Enhanced touch support cannot be used in combination
with InputActions though both can be used side-by-side.
public class MyBehavior : MonoBehaviour
{
protected void OnEnable()
{
EnhancedTouchSupport.Enable();
}
protected void OnDisable()
{
EnhancedTouchSupport.Disable();
}
protected void Update()
{
var activeTouches = Touch.activeTouches;
for (var i = 0; i < activeTouches.Count; ++i)
Debug.Log("Active touch: " + activeTouches[i]);
}
}
Properties
enabled
Whether enhanced touch support is currently enabled.
Declaration
public static bool enabled { get; }
Property Value
Type | Description |
---|---|
Boolean | True if EnhancedTouch support has been enabled. |
Methods
Disable()
Disable enhanced touch support.
Declaration
public static void Disable()
Remarks
This method only undoes a single call to Enable().
Enable()
Enable enhanced touch support.
Declaration
public static void Enable()
Remarks
Calling this method is necessary to enable the functionality provided by Touch and Finger. These APIs add extra processing to touches and are thus disabled by default.
Calls to Enable
and Disable() balance each other out.
If Enable
is called repeatedly, it will take as many calls to
Disable() to disable the system again.