Search Unity

Line Render material / shader

Discussion in '2D' started by aur8l, Jan 25, 2015.

  1. aur8l

    aur8l

    Joined:
    Oct 20, 2014
    Posts:
    3
    Hi,

    I'm working on a little test project (pretty much to get used to Unity 2D features) and started toying around with Line Renderer to dynamically generate a simple level.
    I'm trying to color the line segments based on the height/level/inclination, but I can't get it to work. Here is a screen of what I got :


    Here is what I want :


    I've been trying so far :
    1. To play with the LineRender.SetColors before setting the positions of specific points
    2. To use specific shaders for the LineRenderer
    I could not get it to work so I thought I could spawn prefab (with a 2 points LineRenderer) where I want the gradient, but I don't know how to do this efficiently (all this is done at runtime - before the level starts).

    Could someone give me an approach on this ?

    Thank you.
     
  2. Jessy

    Jessy

    Joined:
    Jun 7, 2007
    Posts:
    7,325
    Please tell us more about this "could not get it to work", using minimal code snippets. I don't think that the Line Renderer mesh has enough data in it to get you what you want, but I'd like to see what you couldn't figure out in your shaders.

    SetColors is a useless method, in my opinion. Why do we have access to all nodes, but only the colors at the beginning and end?
     
    Last edited: Jan 25, 2015