- Home /
Question by
unity_hcxqeZ0HHddHEg · Oct 16, 2020 at 09:07 AM ·
drawing
I want to draw using unity 3d/ How to convert this to work in unity 3d (instead of mouse, how I can I make it draw using my vr controllers?)
public class DrawManager: MonoBehaviour { private LineRenderer lineRenderer; public GameObject drawingPrefab;
void Update()
{
if (Input.GetMouseButtonDown(0))
{
GameObject drawing = Instantiate(drawingPrefab);
lineRenderer = drawing.GetComponent<LineRenderer>();
}
if (Input.GetMouseButton(0))
{
FreeDraw();
}
}
void FreeDraw()
{
lineRenderer.startWidth = 0.1f;
lineRenderer.endWidth = 0.1f;
Vector3 mousePos = new Vector3(Input.mousePosition.x, Input.mousePosition.y, 10f);
lineRenderer.positionCount++;
lineRenderer.SetPosition(lineRenderer.positionCount - 1, Camera.main.ScreenToWorldPoint(mousePos));
}
}
Comment
Your answer

Follow this Question
Related Questions
Why is the System.Drawing namespace not supported in Unity 3.0 Beta? 1 Answer
What is the best way to create a polygon shape in Unity? 3 Answers
Don't delete discrete lines in Vectrosity 2 Answers
How to draw lines/images on 4.6 uGUI Image for a scrollable map? 0 Answers
Draw minimap on panel 2 Answers