本文整理汇总了C#中GestureData.getNormalizedGestureData方法的典型用法代码示例。如果您正苦于以下问题:C# GestureData.getNormalizedGestureData方法的具体用法?C# GestureData.getNormalizedGestureData怎么用?C# GestureData.getNormalizedGestureData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GestureData
的用法示例。
在下文中一共展示了GestureData.getNormalizedGestureData方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: endOfGestureCallback
/// <summary>
/// End of gesture movement callback.
/// </summary>
/// <param name='data'>
/// Data of the gesture gathered.
/// </param>
public void endOfGestureCallback(GestureData data)
{
GestureUtils.EnumGestures gResult;
Debug.Log("Gesture ended!");
List<Vector2> pointList = new List<Vector2>();
GestureData normalizedData = data.getNormalizedGestureData(CANVAS_SIZE);
GestureFrame previousFrame = (GestureFrame)normalizedData.frames[0];
pointList.Add(new Vector2(previousFrame.position.x, previousFrame.position.y));
for (int i = 1; i < normalizedData.frames.Count; i++) {
GestureFrame currentFrame = (GestureFrame)normalizedData.frames[i];
if ((Math.Abs(currentFrame.position.x - previousFrame.position.x) < NORMAL_FRAME_VARIATION) &&
(Math.Abs(currentFrame.position.y - previousFrame.position.y) < NORMAL_FRAME_VARIATION)) {
pointList.Add(new Vector2(currentFrame.position.x, currentFrame.position.y));
previousFrame = currentFrame;
}
}
//At gesture end, draw the normalized data.
Vector2 previousPoint = pointList[0];
for (int i = 1; i < pointList.Count; i++) {
Vector2 currentPoint = pointList[i];
DrawLine(canvas, previousPoint.x, previousPoint.y, currentPoint.x, currentPoint.y, Color.black);
previousPoint = currentPoint;
}
canvas.Apply();
//The checker method only receives canvas if you want the points used drawn on the screen,
//can just receive a points list otherwise.
gResult = gu.GestureChecker(pointList, canvas, CANVAS_SIZE);
switch(gResult) {
case GestureUtils.EnumGestures.DownZigZag:
Debug.Log("Downwards Zig Zag!");
status = "Downwards Zig Zag!";
break;
case GestureUtils.EnumGestures.RightZigZag:
Debug.Log("Rightwards Zig Zag!");
status = "Rightwards Zig Zag!";
break;
case GestureUtils.EnumGestures.Square:
Debug.Log("Square!");
status = "Square!";
break;
default:
Debug.Log("No Gesture found.");
status = "Nothing.";
break;
}
}