Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 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 axCed · Jul 30, 2013 at 06:44 PM · materialcolorline renderer

Is there a technique to change the color of Line Renderer between two points?

I'm working with Line Renderer and I want to change the color of the material between two specific points of the line via script. The goal is to make long segments of the line darker.

I would like to know if you have a technique to do that. Thank you.

Comment
Add comment
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

4 Replies

· Add your reply
  • Sort: 
avatar image
2
Best Answer

Answer by Kiloblargh · Aug 02, 2013 at 06:54 PM

You mean, you were trying to work with the Line Renderer, until you realized its script interface was totally inadequate for what you wanted to achieve, and now you're starting work on a custom procedural mesh generation script to replace it.

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 Kiloblargh · Aug 02, 2013 at 07:18 PM 0
Share

I speak from experience, having wanted to change colors of the TrailRenderer at runtime until I realized you just... plain... can't. The visual effects Unity comes with are great when what you need is exactly what it already does; if not, forget trying to adapt or modify it, you are going to have to go in and get your mesh.vertices dirty.

avatar image axCed · Aug 02, 2013 at 07:39 PM 0
Share

Yep. So, what I understand from your advice is that I should forget about the default line renderer. I like your answer. So the solution is to do a custom procedural mesh generation.

avatar image
1

Answer by DaveA · Aug 02, 2013 at 04:49 PM

Did you not read this? http://docs.unity3d.com/Documentation/ScriptReference/LineRenderer.SetColors.html

So, in hopes that I get upvoted to zero, what if you made your line segements, instead of just 2 points, out of say, 4 points (all co-linear), and set the colors of each segment with the desired colors. If you just used 3 points, for example, you could set the middle point at the 10% distance from the first, and then 10 percent would fade from first to middle color, the last 90% from the middle color to the end color. Use as many segments as you need.

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 perchik · Aug 02, 2013 at 04:51 PM 0
Share

To be fair, that says the color at the start and end, which suggests the whole length of the line will fade between the first color and the second. I think what the OP wants to do is to have each segment of the line fade between two colors

avatar image axCed · Aug 02, 2013 at 07:45 PM 0
Share

SetColors is for the entire line and not just a segment. This goes with what Xtro suggested.

avatar image
-1

Answer by Xtro · Aug 02, 2013 at 04:47 PM

You can draw multiple lines for different segments with different materials. But I doubt if you'll like this idea.

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 axCed · Aug 02, 2013 at 07:44 PM 0
Share

In fact, it would be the ad hoc solution, but I think there will be performance issue. A line can be over 2000 segments long. That's a lot (especially for a mobile game).

avatar image
0

Answer by jfa257 · Mar 24, 2021 at 06:49 PM

I think drawing multiple lines, can be a solution, since basically the line renderer does this for every segment. They put up a quad, and then assign the material to it. So it would give you more control without sacrificing performance. Actually, I think it would be better since leaving the line renderer object to handle all the segments, can be more heavy.

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

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

19 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

Related Questions

Material doesn't have a color property '_Color' 4 Answers

Changing two different objects renderer colour 1 Answer

I want each face of an object to be a different color 1 Answer

Problem getting prefab color 0 Answers

The name 'Joystick' does not denote a valid type ('not found') 2 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