Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Vector2 touchPos = Camera.main.ScreenToWorldPoint(Input.touches[0].position);
- public GameObject linePrefab;
- private Line activeLine;
- private void Update()
- {
- if (Input.touchCount > 0)
- {
- if (Input.GetTouch(0).phase == TouchPhase.Began)
- {
- GameObject lineGO = Instantiate(linePrefab);
- activeLine = lineGO.GetComponent<Line>();
- }
- if (Input.GetTouch(0).phase == TouchPhase.Ended)
- {
- activeLine = null;
- }
- }
- if (activeLine != null)
- {
- Vector2 touchPos = Camera.main.ScreenToWorldPoint(Input.touches[0].position);
- activeLine.UpdateLine(touchPos);
- }
- }
Add Comment
Please, Sign In to add comment