playMaker

Author Topic: Line Renderer Set Gradient  (Read 6208 times)

tcmeric

  • Beta Group
  • Hero Member
  • *
  • Posts: 768
Line Renderer Set Gradient
« on: April 29, 2017, 04:17:16 AM »
So in 5.5, you cannot set a color to a line renderer anymore because it now uses a gradient. (I think its from 5.5 forward).

I needed a 2 color gradient for my lines, so I wrote this. Of course it could also work for 1 color, if you just set both colors to be the same. It also allows you to set the color location, alpha amount and alpha location (time). Basically everything you need to set a color gradient on a line renderer.

Enjoy: https://github.com/dumbgamedev/general-playmaker/tree/master/lineRenderer
« Last Edit: April 29, 2017, 04:19:42 AM by tcmeric »

LordHorusNL

  • Beta Group
  • Full Member
  • *
  • Posts: 226
Re: Line Renderer Set Gradient
« Reply #1 on: April 30, 2017, 07:56:43 AM »
This is exactly what i needed, the current linerender action with 5.5 has a few flaws and this fixes one of the biggest for me!

Awesome, thanks!

tcmeric

  • Beta Group
  • Hero Member
  • *
  • Posts: 768
Re: Line Renderer Set Gradient
« Reply #2 on: April 30, 2017, 08:32:43 AM »
Nice. Thanks for letting me know that it is helpful for you.

What bugs have you noticed with the line renderer in 5.5? Anything in specific?

LordHorusNL

  • Beta Group
  • Full Member
  • *
  • Posts: 226
Re: Line Renderer Set Gradient
« Reply #3 on: April 30, 2017, 11:31:45 AM »
Ohh i was thinking of the draw line action, not the linerenderer itself sorry.

When using the draw line action on a motion controller (Vive) when moving the controller the line always lags behind, even when in late update.
I've noticed the laserpointers in VRTK show the same behaviour.

I've not noticed any other bugs in the linerenderer itself.

tcmeric

  • Beta Group
  • Hero Member
  • *
  • Posts: 768
Re: Line Renderer Set Gradient
« Reply #4 on: April 30, 2017, 11:56:33 AM »
I wonder if something like vectoristy might be more performant. However, I dont have any experience with implementing it.

https://www.assetstore.unity3d.com/en/#!/content/82

LordHorusNL

  • Beta Group
  • Full Member
  • *
  • Posts: 226
Re: Line Renderer Set Gradient
« Reply #5 on: April 30, 2017, 02:46:21 PM »
I'm aware of vectrosity however it's difficult to justify purchasing a 30 dollar asset everytime i run into something unity can't do out of the box.

And that seems to happen far too often :P

tcmeric

  • Beta Group
  • Hero Member
  • *
  • Posts: 768
Re: Line Renderer Set Gradient
« Reply #6 on: April 30, 2017, 09:41:58 PM »
Haha, true. But then again, there will always be someone out there who can do it better and then does (and then sells it). Which is cool by me. Innovation.

S0ULART

  • Playmaker Newbie
  • *
  • Posts: 27
Re: Line Renderer Set Gradient
« Reply #7 on: June 30, 2021, 08:59:30 PM »
does anyone has the corresponding GetLineRendererGradient action to this?
That would be amazing since I cant figure out how to write it myself and failed.

S0ULART

  • Playmaker Newbie
  • *
  • Posts: 27
Re: Line Renderer Set Gradient
« Reply #8 on: July 07, 2021, 02:16:56 PM »
*Please anyone

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: Line Renderer Set Gradient
« Reply #9 on: July 10, 2021, 07:36:41 AM »
Hi.
I think that you need to get this from the material.
you can use : 'Get Material Property Block Float' (instance) or Get Material Float (Material Itself)

probably the named float will be _Gradient but it depends on the material