Skip to content

Instantly share code, notes, and snippets.

@rbaulin
Created September 18, 2015 17:09
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 rbaulin/cd1ec1514858a53b1f66 to your computer and use it in GitHub Desktop.
Save rbaulin/cd1ec1514858a53b1f66 to your computer and use it in GitHub Desktop.
// unity pc and mobile input
// http://docs.unity3d.com/ScriptReference/Input.GetMouseButtonDown.html
// http://docs.unity3d.com/Manual/MobileInput.html
void Update() {
if (SystemInfo.deviceType == DeviceType.Desktop) {
if (Input.GetMouseButtonDown(0)) {// 0 - left click, 1 - right click, 2 - middle click
// click
}
} else {
for (var touch : Touch in Input.touches) {
if (touch.phase == TouchPhase.Began) {
// tap
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment