docs.unity3d.com
    Show / Hide Table of Contents

    Class EnhancedTouchSupport

    API to control enhanced touch facilities like Touch that are not enabled by default.

    Inheritance
    Object
    EnhancedTouchSupport
    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.

    See Also

    Touch
    Finger
    Back to top
    Terms of use
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023