void CreateCat() { if (Input.GetMouseButtonDown(0)) { listGO = Instantiate(list); myPointsScript = listGO.GetComponent <PointsListScript>(); myList = myPointsScript.pointsList; GameObject tailGO = Instantiate(catTailObj); tailGO.transform.parent = listGO.transform; tailGO.transform.localScale = Vector3.zero; tailGO.transform.position = cam.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, 10)); myPointsScript.AddPoint(cam.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, 10))); } if (Input.GetMouseButton(0)) { if (Vector3.Distance(myList[myList.Count - 1], cam.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, 10))) > minDistance) { GameObject bodyGO = Instantiate(catBodyObj); bodyGO.transform.parent = listGO.transform; bodyGO.transform.localScale = Vector3.zero; myPointsScript.AddPoint(cam.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, 10))); bodyGO.transform.position = myList[myList.Count - 1]; } } if (Input.GetMouseButtonUp(0)) { GameObject headGO = Instantiate(catHeadObj); headGO.transform.parent = listGO.transform; headGO.transform.localScale = Vector3.zero; headGO.transform.position = cam.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, 10)); myPointsScript.AddPoint(cam.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, 10))); if (Vector3.Distance(myList[myList.Count - 1], myList[myList.Count - 2]) < 0.25f) { Destroy(listGO.transform.GetChild(listGO.transform.childCount - 2).gameObject); } } }
void CreateCat() { if (Input.GetTouch(0).phase == TouchPhase.Began) { listGO = Instantiate(listObj, root.transform); myPointsScript = listGO.GetComponent <PointsListScript>(); myList = myPointsScript.pointsList; tube = listGO.GetComponent <TubeRenderer>(); touch = Input.GetTouch(0); if (Physics.Raycast(cam.ScreenPointToRay(touch.position), out rayHit, 3f)) { GameObject tailGO = Instantiate(catTailObj, listGO.transform); tailGO.transform.localScale = Vector3.zero; tailGO.transform.position = rayHit.point; myPointsScript.AddPoint(tailGO.transform.position); tube.vertices = new TubeRenderer.TubeVertex[30]; for (int i = 0; i < tube.vertices.Length; i++) { tube.vertices[i] = new TubeRenderer.TubeVertex(Vector3.zero, 1, Color.white); } } } if (Input.GetTouch(0).phase == TouchPhase.Moved || Input.GetTouch(0).phase == TouchPhase.Stationary) { touch = Input.GetTouch(0); if (Physics.Raycast(cam.ScreenPointToRay(touch.position), out rayHit, 3f)) { if (Vector3.Distance(myList[myList.Count - 1], rayHit.point) > minDistance) { myPointsScript.AddPoint(rayHit.point); tube.SetPoints(myPointsScript.splineArray, myPointsScript.radiusArray, Color.white); } } } if (Input.GetTouch(0).phase == TouchPhase.Ended) { touch = Input.GetTouch(0); if (Physics.Raycast(cam.ScreenPointToRay(touch.position), out rayHit, 3f)) { GameObject headGO = Instantiate(catHeadObj, listGO.transform); headGO.transform.localScale = Vector3.zero; headGO.transform.position = myPointsScript.splineArray[myPointsScript.splineArray.Length - 1]; tube.SetPoints(myPointsScript.splineArray, myPointsScript.radius, Color.white); for (int i = 1; i < myPointsScript.splineArray.Length; i++) { GameObject bodyGO = Instantiate(catColliderObj, listGO.transform); bodyGO.transform.position = myPointsScript.splineArray[i]; bodyGO.transform.SetSiblingIndex(i); } } if (myList.Count < 3) { planeObj.SetActive(false); canCreateCat = false; StartCoroutine(ResetCat()); } else { if (openSsInstructions) { StartCoroutine(OpenSsInstructionsScreen()); } else { uiManager.SetScreenshotScreen(); } planeObj.SetActive(false); canCreateCat = false; } } }