Skip to content

Instantly share code, notes, and snippets.

@snlehton
Created December 7, 2016 17:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save snlehton/30c248b95c9471476af418ba3cbee24c to your computer and use it in GitHub Desktop.
Save snlehton/30c248b95c9471476af418ba3cbee24c to your computer and use it in GitHub Desktop.
"Better" version of the Unity UI.Button which prevents the button from becoming selected upon mouse click
using UnityEngine.EventSystems;
using UnityEngine.UI;
public class BetterButton : Button
{
public override void OnSelect(BaseEventData eventData)
{
// prevent the button on becoming selected via mouse click
if (eventData is PointerEventData)
{
return;
}
base.OnSelect(eventData);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment