if (platform == RuntimePlatform.Android) {
if (Input.touchCount > 0) {
virtualKeyPosition = new Vector3(Input.GetTouch(0).position.x, Input.GetTouch(0).position.y);
}
} else {
if (Input.GetMouseButton(0)) {
virtualKeyPosition = new Vector3(Input.mousePosition.x, Input.mousePosition.y);
}
}
if (drawArea.Contains(virtualKeyPosition)) {
if (Input.GetMouseButtonDown(0)) {
points.Clear();
gestureLineRenderer.SetVertexCount(0);
vertexCount = 0;
}
if (Input.GetMouseButton(0)) {
points.Add(new Vector2(virtualKeyPosition.x, -virtualKeyPosition.y));
gestureLineRenderer.SetVertexCount(++vertexCount);
gestureLineRenderer.SetPosition(vertexCount - 1, WorldCoordinateForGesturePoint(virtualKeyPosition));
}
if (Input.GetMouseButtonUp(0)) {
Gesture g = new Gesture(points);
Result result = g.Recognize(gl, true);
message = result.Name + "; " + result.Score;
}
}
private Vector3 WorldCoordinateForGesturePoint(Vector3 gesturePoint) {
Vector3 worldCoordinate = new Vector3(gesturePoint.x, gesturePoint.y, 10);
return Camera.main.ScreenToWorldPoint(worldCoordinate);
}