docs.unity3d.com
Search Results for

    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
    Assembly: Unity.InputSystem.dll
    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
    bool

    True if EnhancedTouch support has been enabled.

    See Also
    Touch
    Finger

    Methods

    Disable()

    Disable enhanced touch support.

    Declaration
    public static void Disable()
    Remarks

    This method only undoes a single call to Enable().

    See Also
    Touch
    Finger

    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

    See Also

    Touch
    Finger
    In This Article
    Back to top
    Copyright © 2024 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)