Skip to content

Instantly share code, notes, and snippets.

@Josef212
Created June 26, 2019 12:47
Show Gist options
  • Save Josef212/1e04ff11afd9ae52d727d848067d2acd to your computer and use it in GitHub Desktop.
Save Josef212/1e04ff11afd9ae52d727d848067d2acd to your computer and use it in GitHub Desktop.
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;
}
@Josef212
Copy link
Author

Should change s_referenceWidth for canvas scaler reference width

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment