// Update is called once per frame void Update() { //Check ditances among points only if 4 points are registered contemporary if (Input.touches.Length == 4 && !found && !recognized) { // WidgetRecognition Part currentWidget = new WidgetCM(Input.touches); recognized = currentWidget.IdentifyWidget(); if (recognized) { found = true; recognizedWidgets++; IDPointDistancesCM.Add(currentWidget.GetIDTouchPointDistCM()); WidgetID = currentWidget.GetWidgetID(IdentificationType); ChangeWidgetColor(); recognizedWidgetsList.Add(currentWidget); //transform.localScale = OnTouchSpriteScale; transform.localScale = Vector3.Lerp(transform.localScale, OnTouchSpriteScale, 15 * Time.deltaTime); if (follow && UpdatePosition) SpriteFollow(currentWidget.OrderedTouchPoints[0]); //UpdateSpritePosition(currentWidget.DataPointTouch); UpdateSpriteRotation(currentWidget.angle); } else { nonRecognizedWidgets++; } } else if (Input.touches.Length == 4 && found && recognized && ContinuosUpdate) { currentWidget.UpdateTouchPoints(Input.touches); recognized = currentWidget.IdentifyWidget(); if (recognized) { recognizedWidgets++; IDPointDistancesCM.Add(currentWidget.GetIDTouchPointDistCM()); transform.localScale = Vector3.Lerp(transform.localScale, OnTouchSpriteScale, 15 * Time.deltaTime); // Translations Updates if (follow && UpdatePosition) SpriteFollow(currentWidget.OrderedTouchPoints[0]); else if (UpdatePosition && !follow) UpdateSpritePosition(currentWidget.OrderedTouchPoints[0]); //Rotation Update if (UpdateRotation && !AngleSlider) UpdateSpriteRotation(currentWidget.angle); } else { nonRecognizedWidgets++; found = false; } } //All touches have been removed from screen else if (Input.touches.Length == 0) { found = false; recognized = false; transform.localScale = Vector3.Lerp(transform.localScale, originalSquareSize, 15 * Time.deltaTime); } UpdateStats(); }
private string TouchPointsData(WidgetCM w) { StringBuilder sb = new StringBuilder("Touch Points:").AppendLine(); sb.Append("Origin: " + w.OrderedTouchPoints[0].position.ToString()).AppendLine(); sb.Append("X: " + w.OrderedTouchPoints[1].position.ToString()).AppendLine(); sb.Append("Y: " + w.OrderedTouchPoints[2].position.ToString()).AppendLine(); sb.Append("Data: " + w.OrderedTouchPoints[3].position.ToString()).AppendLine(); return sb.ToString(); }