Guest User

Untitled

a guest
Jan 16th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. Vector2 touchPos = Camera.main.ScreenToWorldPoint(Input.touches[0].position);
  2.  
  3. public GameObject linePrefab;
  4. private Line activeLine;
  5.  
  6. private void Update()
  7. {
  8. if (Input.touchCount > 0)
  9. {
  10. if (Input.GetTouch(0).phase == TouchPhase.Began)
  11. {
  12. GameObject lineGO = Instantiate(linePrefab);
  13. activeLine = lineGO.GetComponent<Line>();
  14. }
  15.  
  16. if (Input.GetTouch(0).phase == TouchPhase.Ended)
  17. {
  18. activeLine = null;
  19. }
  20. }
  21.  
  22. if (activeLine != null)
  23. {
  24. Vector2 touchPos = Camera.main.ScreenToWorldPoint(Input.touches[0].position);
  25. activeLine.UpdateLine(touchPos);
  26. }
  27. }
Add Comment
Please, Sign In to add comment