Created
March 27, 2017 14:00
-
-
Save keithweaver/7da0247b0a9551d8b456396d37755ad7 to your computer and use it in GitHub Desktop.
Handle touch input or mouse click with Unity
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
// Example of handling click or touch down in Unity | |
using System.Collections; | |
using System.Collections.Generic; | |
using Unity; | |
public class CharacterMovement : MonoBehaviour { | |
void start() { | |
Debug.Log("Start"); | |
} | |
void update() { | |
if (Input.touchCount > 0 || Input.GetMouseButtonDown(0)) { | |
// Either touch down or Mouse click | |
Debug.Log("Explosion"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I tested it on android (one click add one shot) and it continuously add shot. As "Input.GetMouseButtonDown(0)" work in android, you can remove "Input.touchCount > 0 ||" from =the condition and now it will work.