Created
May 15, 2018 18:31
-
-
Save fabian71/e0d490f8ca4850d8b446c7d465315cfa to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System.Collections; | |
| using System.Collections.Generic; | |
| using UnityEngine; | |
| public class LinhaScript : MonoBehaviour { | |
| int numeroDeVertices = 0; | |
| LineRenderer linha; | |
| bool apertandoBotaoDoMouse = false; | |
| // Use this for initialization | |
| void Start () { | |
| linha = GetComponent<LineRenderer>(); | |
| } | |
| // Update is called once per frame | |
| void Update () { | |
| if(Input.GetMouseButtonDown(0)){ | |
| apertandoBotaoDoMouse = true; | |
| } | |
| if(Input.GetMouseButtonUp(0)){ | |
| apertandoBotaoDoMouse = false; | |
| } | |
| if(apertandoBotaoDoMouse){ | |
| CriarLinha(); | |
| }else{ | |
| DeletarLinha(); | |
| } | |
| } | |
| void CriarLinha() { | |
| linha.SetVertexCount (numeroDeVertices + 1); | |
| Debug.Log(Input.mousePosition); | |
| Vector3 posicaoDoMouse = Camera.main.ScreenToWorldPoint(Input.mousePosition); | |
| linha.SetPosition(numeroDeVertices, posicaoDoMouse); | |
| numeroDeVertices++; | |
| } | |
| void DeletarLinha() { | |
| numeroDeVertices = 0; | |
| linha.SetVertexCount(0); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment