need to create reactagle based on mouse coordinates while playing game?

Hi, I am new to Unity. I am creating a 2d game where user can create a rectangle when touch happen. When user touch the screen, it create a new rectangle big as user want inside the screen. Well, i don’t know how mouse coordinates works in unity classes but i have the example similar to what i want, attached in link. If I get some help, i appreciate it.

You read the mouse coords using Input, generally in your Update function:

What you get are screen X and Y (and 0 for Z).

You can convert those to world coords using Camera.main.ScreenToWorldPoint

Now, how you draw your triangle is another matter and depends on what you are trying to do. In general
however line drawing in Unity is non-trivial.