Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by romelleayala · Oct 05, 2018 at 03:18 AM · line renderer

how to make a dotted line renderer ?

i dont have any idea on this. can someone please enlighten me ? any help is appreciated. thanks!

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image VengadoraVG · May 14, 2021 at 11:41 AM 0
Share

PROTIP: SET YOUR TEXTURE'S WRAP MODE TO REPEAT

6 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Bradybeast128 · Oct 05, 2018 at 02:23 PM

@romelleayala You could just set the material of a line renderer to a texture of a dotted line and then have the material repeat. Hope this helps!

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image samuelogan987 · Dec 31, 2018 at 12:20 PM 0
Share

Line renderers don't support transparency, so it only works if what is behind the line render is a solid colour.

avatar image samuelogan987 samuelogan987 · Dec 31, 2018 at 12:26 PM 0
Share

Never$$anonymous$$d, I was using an unlit texture shader ins$$anonymous$$d of a unlit transparency shader. Your method works perfectly. Thanks!

avatar image
1

Answer by Solocov · Jan 08, 2021 at 10:51 AM

Since it took way to long to fix this myself here is the complete solution:

https://www.reddit.com/r/Unity2D/comments/kt01nv/dotted_linerenderer_fixed/

Hope this helps!

alt text


dottedparabel.png (8.6 kB)
Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Olakehs · Apr 09, 2021 at 06:26 AM 0
Share

This was really helpful. Thank you

avatar image
0

Answer by KirillKuzyk · Oct 29, 2019 at 10:37 AM

Both LineRenderer and TrailRenderer have a property TextureMode. Set it to Tile or RepeatPerSegment to achieve a dotted or dashed line.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by KT1994 · Aug 23, 2019 at 06:07 AM

For me it didn't worked. The only solution I found is to create a script that creates a dotted line. I have also written a blog to share how I achieved this.

https://www.knowledgescoops.com/2019/07/creating-dotted-line-in-unity_29.html

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by vovo801 · Feb 13, 2020 at 04:32 PM

Had to do the same thing in Unity 2019.3. Even though the TextureMode field exists on the LineRenderer, I was not able to figure out the correct math for not distorting the dots. So, I went with TextureMode set to Stretch. On the texture that I used as the dot on the line, I set WrapMode to Repeat. Edited the texture in PS to add some padding to spread the dots apart from each other (Canvas Size in PS). Created a material with this texture. Used the shader Mobile/Particles/AlphaBlended.

Here's a script that I used on my dotted line prefab (attached to the same object that has the LineRenderer component):

using UnityEngine;

public class DottedLineRenderer : MonoBehaviour { public bool scaleInUpdate = false; private LineRenderer lR; private Renderer rend;

  private void Start () 
  {
      ScaleMaterial();
      enabled = scaleInUpdate;
  }
 
  public void ScaleMaterial()
  {
      lR = GetComponent<LineRenderer>();
      rend = GetComponent<Renderer>();
      rend.material.mainTextureScale =
          new Vector2(Vector2.Distance(lR.GetPosition(0), lR.GetPosition(lR.positionCount - 1)) / lR.widthMultiplier,
              1);
  }
 
  private void Update ()
  {
      rend.material.mainTextureScale =
          new Vector2(Vector2.Distance(lR.GetPosition(0), lR.GetPosition(lR.positionCount - 1)) / lR.widthMultiplier,
              1);
  }

} Another issue that I've encountered - I wanted to fade the start and end of the line into transparency by setting the color gradient on the line. For some reason this did not work for me if the line had only 2 points and both ends were transparent, but it did work when the line had more than 2 points. Here's the code that I used to resolve this and add more points to the line:

// line renderer with 2 points only does not handle transparency properly: lineRenderer.positionCount = linePointsCount; // I used linePointsCount = 10 for (var i = 0; i < linePointsCount; i++) { lineRenderer.SetPosition(i, Vector3.Lerp(fromPoint, toPoint, (float) i / (linePointsCount - 1))); }

      var dottedLine = lineObject.GetComponent<DottedLineRenderer>();
      if(dottedLine != null) dottedLine.ScaleMaterial();

I hope this helps someone.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
  • 1
  • 2
  • ›

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

98 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Need help setting correct Y height for laser beam with 50 elements 2 Answers

How to make a Line Renderer thin out only near the ends? Alternatively, how to apply 3-way slicing? 1 Answer

How to detect objects around a position and add them to a list 2 Answers

line renderer to draw multiple lines 1 Answer

Cutout mask using dynamically drawn lines? 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges