docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class OnScreenStick

    A stick control displayed on screen and moved around by touch or other pointer input.

    Inheritance
    object
    Object
    Component
    Behaviour
    MonoBehaviour
    OnScreenControl
    OnScreenStick
    Implements
    IPointerDownHandler
    IPointerUpHandler
    IDragHandler
    IEventSystemHandler
    Inherited Members
    OnScreenControl.controlPath
    OnScreenControl.control
    OnScreenControl.SendValueToControl<TValue>(TValue)
    OnScreenControl.SentDefaultValueToControl()
    OnScreenControl.OnEnable()
    OnScreenControl.OnDisable()
    MonoBehaviour.IsInvoking()
    MonoBehaviour.CancelInvoke()
    MonoBehaviour.Invoke(string, float)
    MonoBehaviour.InvokeRepeating(string, float, float)
    MonoBehaviour.CancelInvoke(string)
    MonoBehaviour.IsInvoking(string)
    MonoBehaviour.StartCoroutine(string)
    MonoBehaviour.StartCoroutine(string, object)
    MonoBehaviour.StartCoroutine(IEnumerator)
    MonoBehaviour.StopCoroutine(IEnumerator)
    MonoBehaviour.StopCoroutine(Coroutine)
    MonoBehaviour.StopCoroutine(string)
    MonoBehaviour.StopAllCoroutines()
    MonoBehaviour.print(object)
    MonoBehaviour.useGUILayout
    MonoBehaviour.runInEditMode
    Behaviour.enabled
    Behaviour.isActiveAndEnabled
    Component.GetComponent(Type)
    Component.GetComponent<T>()
    Component.TryGetComponent(Type, out Component)
    Component.TryGetComponent<T>(out T)
    Component.GetComponent(string)
    Component.GetComponentInChildren(Type, bool)
    Component.GetComponentInChildren(Type)
    Component.GetComponentInChildren<T>(bool)
    Component.GetComponentInChildren<T>()
    Component.GetComponentsInChildren(Type, bool)
    Component.GetComponentsInChildren(Type)
    Component.GetComponentsInChildren<T>(bool)
    Component.GetComponentsInChildren<T>(bool, List<T>)
    Component.GetComponentsInChildren<T>()
    Component.GetComponentsInChildren<T>(List<T>)
    Component.GetComponentInParent(Type)
    Component.GetComponentInParent<T>()
    Component.GetComponentsInParent(Type, bool)
    Component.GetComponentsInParent(Type)
    Component.GetComponentsInParent<T>(bool)
    Component.GetComponentsInParent<T>(bool, List<T>)
    Component.GetComponentsInParent<T>()
    Component.GetComponents(Type)
    Component.GetComponents(Type, List<Component>)
    Component.GetComponents<T>(List<T>)
    Component.GetComponents<T>()
    Component.CompareTag(string)
    Component.SendMessageUpwards(string, object, SendMessageOptions)
    Component.SendMessageUpwards(string, object)
    Component.SendMessageUpwards(string)
    Component.SendMessageUpwards(string, SendMessageOptions)
    Component.SendMessage(string, object)
    Component.SendMessage(string)
    Component.SendMessage(string, object, SendMessageOptions)
    Component.SendMessage(string, SendMessageOptions)
    Component.BroadcastMessage(string, object, SendMessageOptions)
    Component.BroadcastMessage(string, object)
    Component.BroadcastMessage(string)
    Component.BroadcastMessage(string, SendMessageOptions)
    Component.transform
    Component.gameObject
    Component.tag
    Object.GetInstanceID()
    Object.GetHashCode()
    Object.Equals(object)
    Object.Instantiate(Object, Vector3, Quaternion)
    Object.Instantiate(Object, Vector3, Quaternion, Transform)
    Object.Instantiate(Object)
    Object.Instantiate(Object, Transform)
    Object.Instantiate(Object, Transform, bool)
    Object.Instantiate<T>(T)
    Object.Instantiate<T>(T, Vector3, Quaternion)
    Object.Instantiate<T>(T, Vector3, Quaternion, Transform)
    Object.Instantiate<T>(T, Transform)
    Object.Instantiate<T>(T, Transform, bool)
    Object.Destroy(Object, float)
    Object.Destroy(Object)
    Object.DestroyImmediate(Object, bool)
    Object.DestroyImmediate(Object)
    Object.FindObjectsOfType(Type)
    Object.DontDestroyOnLoad(Object)
    Object.FindObjectsOfType<T>()
    Object.FindObjectOfType<T>()
    Object.FindObjectOfType(Type)
    Object.ToString()
    Object.name
    Object.hideFlags
    Namespace: UnityEngine.InputSystem.OnScreen
    Assembly: Unity.InputSystem.dll
    Syntax
    [AddComponentMenu("Input/On-Screen Stick")]
    [HelpURL("https://docs.unity3d.com/Packages/com.unity.inputsystem@1.8/manual/OnScreen.html#on-screen-sticks")]
    public class OnScreenStick : OnScreenControl, IPointerDownHandler, IPointerUpHandler, IDragHandler, IEventSystemHandler
    Remarks

    The OnScreenStick works by simulating events from the device specified in the controlPath property. Some parts of the Input System, such as the PlayerInput component, can be set up to auto-switch to a new device when input from them is detected. When a device is switched, any currently running inputs from the previously active device are cancelled. In the case of OnScreenStick, this can mean that the UnityEngine.EventSystems.IPointerUpHandler.OnPointerUp(UnityEngine.EventSystems.PointerEventData) method will be called and the stick will jump back to center, even though the pointer input has not physically been released.

    To avoid this situation, set the useIsolatedInputActions property to true. This will create a set of local Input Actions to drive the stick that are not cancelled when device switching occurs.

    Properties

    behaviour

    Defines how the onscreen stick will move relative to it's origin and the press position.

    Declaration
    public OnScreenStick.Behaviour behaviour { get; set; }
    Property Value
    Type Description
    OnScreenStick.Behaviour

    controlPathInternal

    Accessor for the controlPath of the component. Must be implemented by subclasses.

    Declaration
    protected override string controlPathInternal { get; set; }
    Property Value
    Type Description
    string
    Overrides
    OnScreenControl.controlPathInternal
    Remarks

    Moving the definition of how the control path is stored into subclasses allows them to apply their own InputControlAttribute attributes to them and thus set their own layout filters.

    dynamicOriginRange

    Defines the circular region where the onscreen control may have it's origin placed.

    Declaration
    public float dynamicOriginRange { get; set; }
    Property Value
    Type Description
    float
    Remarks

    This only applies if behaviour is set to ExactPositionWithDynamicOrigin. When the first press is within this region, then the control will appear at that position and have it's origin of motion placed there. Otherwise, if pressed outside of this region the control will ignore it. This property defines the radius of the circular region. The center point being defined by the component position in the scene.

    movementRange

    The distance from the onscreen control's center of origin, around which the control can move.

    Declaration
    public float movementRange { get; set; }
    Property Value
    Type Description
    float

    useIsolatedInputActions

    Prevents stick interactions from getting cancelled due to device switching.

    Declaration
    public bool useIsolatedInputActions { get; set; }
    Property Value
    Type Description
    bool
    Remarks

    This property is useful for scenarios where the active device switches automatically based on the most recently actuated device. A common situation where this happens is when using a PlayerInput component with Auto-switch set to true. Imagine a mobile game where an on-screen stick simulates the left stick of a gamepad device. When the on-screen stick is moved, the Input System will see an input event from a gamepad and switch the active device to it. This causes any active actions to be cancelled, including the pointer action driving the on screen stick, which results in the stick jumping back to the center as though it had been released.

    In isolated mode, the actions driving the stick are not cancelled because they are unique Input Action instances that don't share state with any others.

    Methods

    OnDrag(PointerEventData)

    Callback to handle OnDrag UI events.

    Declaration
    public void OnDrag(PointerEventData eventData)
    Parameters
    Type Name Description
    PointerEventData eventData

    OnPointerDown(PointerEventData)

    Callback to handle OnPointerDown UI events.

    Declaration
    public void OnPointerDown(PointerEventData eventData)
    Parameters
    Type Name Description
    PointerEventData eventData

    OnPointerUp(PointerEventData)

    Callback to handle OnPointerUp UI events.

    Declaration
    public void OnPointerUp(PointerEventData eventData)
    Parameters
    Type Name Description
    PointerEventData eventData

    Implements

    UnityEngine.EventSystems.IPointerDownHandler
    UnityEngine.EventSystems.IPointerUpHandler
    UnityEngine.EventSystems.IDragHandler
    UnityEngine.EventSystems.IEventSystemHandler
    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)