Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Resolved Disable snap back of a on-screen stick

Discussion in 'Input System' started by Bliggfang, Aug 14, 2022.

  1. Bliggfang

    Bliggfang

    Joined:
    Sep 8, 2021
    Posts:
    8
    Is there a way that a on-screen stick (Unity Input System) doesn't snap back to its original position on pointer up?
     
  2. Bliggfang

    Bliggfang

    Joined:
    Sep 8, 2021
    Posts:
    8
    SOLVED

    Sorry, noob-question! :p

    Just don't use the original OnScreenStick script, but make a copy and adjust OnPointerUp there. Something like this:

    Original:
    Code (CSharp):
    1. public void OnPointerUp(PointerEventData eventData)
    2. {
    3.     ((RectTransform)transform).anchoredPosition = m_StartPos;
    4.     SendValueToControl(Vector2.zero);
    5. }
    Adaption:
    Code (CSharp):
    1. public void OnPointerUp(PointerEventData eventData)
    2. {
    3.     // do nothing
    4. }