Advertisement
Guest User

Untitled

a guest
Jul 19th, 2021
2,454
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class DrawManager : MonoBehaviour {
  6. private Camera _cam;
  7. [SerializeField] private Line _linePrefab;
  8.  
  9. public const float RESOLUTION = .1f;
  10.  
  11. private Line _currentLine;
  12. void Start()
  13. {
  14. _cam = Camera.main;
  15. }
  16.  
  17.  
  18. void Update() {
  19. Vector2 mousePos = _cam.ScreenToWorldPoint(Input.mousePosition);
  20.  
  21. if (Input.GetMouseButtonDown(0)) _currentLine = Instantiate(_linePrefab, mousePos, Quaternion.identity);
  22.  
  23. if(Input.GetMouseButton(0)) _currentLine.SetPosition(mousePos);
  24. }
  25. }
  26.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement