diff options
| author | Simon O'Shea <osheas1@wit.edu> | 2023-07-30 14:32:04 -0400 |
|---|---|---|
| committer | Simon O'Shea <osheas1@wit.edu> | 2023-07-30 14:32:04 -0400 |
| commit | 8b7b130a9f49371bbe79aa49fe78f7435ea761d6 (patch) | |
| tree | 6f9509c88bed7080d496fc5e1d87a9315e30549d /Pathfinding Visualizer/Assets/Scripts/DrawLine.cs | |
| parent | e7b56ebf9d25978b3aac4a0631d4083fdb2441d1 (diff) | |
nuked
wiping everything to start again
Diffstat (limited to 'Pathfinding Visualizer/Assets/Scripts/DrawLine.cs')
| -rw-r--r-- | Pathfinding Visualizer/Assets/Scripts/DrawLine.cs | 61 |
1 files changed, 0 insertions, 61 deletions
diff --git a/Pathfinding Visualizer/Assets/Scripts/DrawLine.cs b/Pathfinding Visualizer/Assets/Scripts/DrawLine.cs deleted file mode 100644 index e3b2e47..0000000 --- a/Pathfinding Visualizer/Assets/Scripts/DrawLine.cs +++ /dev/null @@ -1,61 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class DrawLine : MonoBehaviour -{ - - public GameObject linePrefab; - public GameObject currentLine; - - public LineRenderer lineRenderer; - public EdgeCollider2D edgeCollider; - public List<Vector2> fingerPositions; - - - - // Start is called before the first frame update - void Start() - { - - } - - // Update is called once per frame - void Update() - { - if (Input.GetMouseButtonDown(0)) - { - CreateLine(); - } - - if (Input.GetMouseButton(0)) - { - Vector2 tempFingerPos = Camera.main.ScreenToWorldPoint(Input.mousePosition); - if (Vector2.Distance(tempFingerPos, fingerPositions[fingerPositions.Count - 1]) > .1f) - { - UpdateLine(tempFingerPos); - } - } - } - - void CreateLine() - { - currentLine = Instantiate(linePrefab, Vector3.zero, Quaternion.identity); - lineRenderer = currentLine.GetComponent<LineRenderer>(); - edgeCollider = currentLine.GetComponent<EdgeCollider2D>(); - fingerPositions.Clear(); - fingerPositions.Add(Camera.main.ScreenToWorldPoint(Input.mousePosition)); - fingerPositions.Add(Camera.main.ScreenToWorldPoint(Input.mousePosition)); - lineRenderer.SetPosition(0, fingerPositions[0]); - lineRenderer.SetPosition(1, fingerPositions[1]); - edgeCollider.points = fingerPositions.ToArray(); - - } - void UpdateLine(Vector2 newFingerPos) - { - fingerPositions.Add(newFingerPos); - lineRenderer.positionCount++; - lineRenderer.SetPosition(lineRenderer.positionCount - 1, newFingerPos); - edgeCollider.points = fingerPositions.ToArray(); - } -} |
