public void ClearTouchMarker(int touchId) { SpMarker marker = spMarkers.Find(SpMarker => SpMarker.touchId == touchId); Destroy(marker.collider2D); Destroy(marker.collider3D); spMarkers.RemoveAt(spMarkers.IndexOf(marker)); }
public void UpdateTouchMarker(int touchId, Vector3 updatedPosition) { // Debug.Log("touch marker moving: " + touchId); SpMarker thisSp = spMarkers.Find(SpMarker => SpMarker.touchId == touchId); Vector2 newPos = new Vector2(updatedPosition.x, updatedPosition.y); thisSp.collider2D.transform.position = newPos; Ray castPoint = Camera.main.ScreenPointToRay(updatedPosition); RaycastHit hit; if (Physics.Raycast(castPoint, out hit, Mathf.Infinity, smartTouchHitLayers)) { thisSp.collider3D.transform.position = hit.point; } }
public SpMarker CreateTouchMarker2D(Vector3 spawnPosisiton, int touchID, string label, string uid) { GameObject touchMarker2D = Instantiate(touchMarker2DPrefab, spawnPosisiton, Quaternion.identity); touchMarker2D.transform.parent = goCanvas.transform; touchMarker2D.transform.position = spawnPosisiton; GameObject touchMarker3D = Instantiate(touchMarkerPrefab, spawnPosisiton, Quaternion.identity); SpMarker marker = new SpMarker(touchID, touchMarker2D, touchMarker3D); marker.SetSmartPieceData(uid, label); marker.SetDebugInfo(label, uid, String.Format("{0},{1}", spawnPosisiton.x.ToString(), spawnPosisiton.y.ToString()), touchID.ToString()); spMarkers.Add(marker); return(marker); }