Created
June 26, 2019 12:47
-
-
Save Josef212/1e04ff11afd9ae52d727d848067d2acd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using UnityEngine.EventSystems; | |
public class SensitiveInteractuables : MonoBehaviour, IPointerDownHandler, IPointerUpHandler | |
{ | |
public void OnPointerDown(PointerEventData eventData) | |
{ | |
m_initialDragThreshold = EventSystem.current.pixelDragThreshold; | |
EventSystem.current.pixelDragThreshold = m_newTreshold; | |
} | |
public void OnPointerUp(PointerEventData eventData) | |
{ | |
EventSystem.current.pixelDragThreshold = m_initialDragThreshold; | |
} | |
private const int c_referecneThreshold = 100; | |
private int m_newTreshold = (int)((float)c_referecneThreshold / UIManager.s_referenceWidth * Screen.width); | |
private int m_initialDragThreshold = 5; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Should change s_referenceWidth for canvas scaler reference width