Use Dashed Lines with Polylines ?

Avatar
  • updated
  • Answered

Hi, i succeed to make my trajectory with polyline but i would like to know if that is possible to transform this polyline into several dashed lines ?

Reporting a bug? please specify Unity version:
Reporting a bug? please specify Shapes version:
Reporting a bug? please specify Render Pipeline:
Built-in render pipeline
Avatar
hugo lammens

And my second question is : how did you make this ?

Image 662

Avatar
hugo lammens

Thanks i will look at it, and is that possible to change color during time for Polyline ?

Avatar
Freya Holmér creator
Quote from hugo lammens

Thanks i will look at it, and is that possible to change color during time for Polyline ?

sure, you can change colors of both components and set color in immediate mode. or set colors of individual points in the polyline

Avatar
hugo lammens
Quote from Freya Holmér

sure, you can change colors of both components and set color in immediate mode. or set colors of individual points in the polyline

Im using this just before the drawing : Poly.AddPoints(trajectory, thickness); I had all points of trajectory, so i have to change color of point in trajectory before adding them into Poly (which is my PolylinePath)?

Avatar
Freya Holmér creator
Quote from hugo lammens

Im using this just before the drawing : Poly.AddPoints(trajectory, thickness); I had all points of trajectory, so i have to change color of point in trajectory before adding them into Poly (which is my PolylinePath)?

yeah, or modify them before drawing, or use the global color value of the polyline itself

Avatar
hugo lammens
Quote from Freya Holmér

yeah, or modify them before drawing, or use the global color value of the polyline itself

Sorry to ask you a lot but im a beginner at this. What do you mean by modifying them before drawing, is that not the same than changing color before adding them into my PolylinePath ? And second, how do we use global color value of polyline ?

Avatar
Freya Holmér creator

You can either set colors before adding them to the polylinepath, or you can modify the points you've already added to the path

// sets color when adding
path.AddPoint( new Vector2( 1,2 ), Color.red );

// changes color after you've already added points
path.SetColor( index: 0, Color.red );

// Draws the whole polyline tinted by the global color red
Draw.Polyline( path, Color.red );
Avatar
hugo lammens
Quote from Freya Holmér

You can either set colors before adding them to the polylinepath, or you can modify the points you've already added to the path

// sets color when adding
path.AddPoint( new Vector2( 1,2 ), Color.red );

// changes color after you've already added points
path.SetColor( index: 0, Color.red );

// Draws the whole polyline tinted by the global color red
Draw.Polyline( path, Color.red );

Ok thanks you, is that possible to know the size of a PolylinePath ?

Avatar
Freya Holmér creator
PolylinePath.Count