Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rounded end cap 2d lines in unity5

                greyLine.SetWidth (0.4F, 0.4F);
                greyLine.SetColors (Color.grey, Color.grey);
                Material lineGrey = new Material (Shader.Find ("Particles/Alpha Blended"));
                greyLine.material = lineGrey;
                greyLine.SetVertexCount (2);
                greyLine.SetPosition (0, h0);
                greyLine.SetPosition (1, pos);

I'm creating a line like this. i want the end points of the lines to be round caps. But there are no similar options as there is in android studio for e.g., paint (Paint.Cap.ROUND). Is there any similar way I can do that? I'm trying to create a drag based scene like in basic wordgames etc (e.g. WordSearch games).

like image 632
ree1991 Avatar asked Nov 09 '22 23:11

ree1991


1 Answers

I quess it is LineRenderer. You cannot do this using LineRenderer component, but you can do this with material.

Create sprite with rounded ends. Cut it down in sprite editor in the middle, so the rounded parts are out of cut area. Doing so the area inside cut will be streched, but rounded parts of sprite will ramain aspect.

Create material with this sprite, and assign to the LineRenderer.

like image 188
Jerry Switalski Avatar answered Nov 14 '22 23:11

Jerry Switalski