Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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
2
Question by chrisps89 · Feb 06, 2013 at 11:32 PM · materiallinerendererpink

Problem with line renderer material

I am trying to just add a material to the line that is rendered but I am only seeing a magenta line. The material is in the project and so it is not missing, but yet the line renderer just seems to ignore the material I have assigned to it. Code show below;

 var startWidth = 0.05;
 var endWidth = 0.05;
 var aMaterial : Material;
 
 private var line : LineRenderer;
 
 function Start ()
 {
    line = this.gameObject.AddComponent(LineRenderer);
    //line.material = new Material (Shader.Find("Particles/Additive"));
    line.SetWidth(startWidth, endWidth);
    line.SetVertexCount(2);   
    line.material = aMaterial;
    line.renderer.enabled = true;
 }

Any help would be greatly appreciated.

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

3 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by FerdieQO · Nov 11, 2013 at 03:17 PM

First of all, this line = this.gameObject.AddComponent(LineRenderer); should be this line = this.gameObject.AddComponent();. Argument of the AddComponent should be empty, only the type assignment operators <> to define its type. But that's not going to solve your problem.

I've been stuck with the same problem but luckily I found a solution. You'll need a simple, constant, self-illuminating material (so NOT one of the Particle materials) and assign that one to the lineRenderer (this works best in the editor).

  • Add a LineRenderer component to the gameobject via the Unity Editor

  • Change this: line = this.gameObject.AddComponent(LineRenderer); to this:

    line = gameObject.GetComponent();

  • Make a new material with a Self-Illumin/Diffuse and assign a color to it (no texture!)

  • Assign the new material to the LineRenderer component in the Unity Editor

This worked for me, hopefully you'll be helped with this too :)

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
1

Answer by FlightOfOne · Feb 24, 2016 at 01:31 AM

I know this is an old post but might help someone else. To get the built in start / end colors this is what I did. Not that this is a very quick solution.

  1. Create an Empty object

  2. Add component > Effects> Line Renderer

  3. Create a material

  4. Change the Shader Particles Alpha Blend. Particles>Alpha Blend.

  5. Add the Material to Line Renderer Materials

Most of the particle shaders will work but Alpha blend gave me the best look. I didn't have to do any coding for this part. Only code I had to display the line was setting the positions.

 ///------------------------------
 LineRenderer lr;
 
 Void Start()
 {
       lr = GetComponent<LineRenderer>();
       lr.SetPositions(points); //points=an array of points(Vector3)
 }
 ///------------------------------------------
 






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 ShawnFeatherly · Nov 28, 2015 at 07:00 AM

Self-Illumin/Diffuse didn't work well for me. This 6 line shader taken from another similar question did tho: http://answers.unity3d.com/questions/34437/shader-needed-for-gradients-using-a-linerenderer.html

 Shader "Vertex Colors" {
  Subshader {
   BindChannels {
     Bind "vertex", vertex
     Bind "color", color 
   }
   Pass {}
  }
 }
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

12 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

Related Questions

Multiple Cars not working 1 Answer

Can't select shader help! 1 Answer

Chain Texture for Line Renderer 1 Answer

Android Audio Delay 0 Answers

Problem with SSL CA cert 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