- Home /
How do I get a line renderer to draw over sprites?
I've been trying to get a line renderer to draw over sprites, but I haven't been able to do it. I've also tried searching, but could not find an answer.
If it isn't possible, is there an alternative way to draw a line?
Has this been solved yet? I recently saw this post but I'm not sure if particle system & lineRenderer are necessarily the same bucket.
answers.unity3d.com/questions/577288/particle-system-rendering-behind-sprites.html
Answer by E_Sarkis · Jul 07, 2017 at 07:39 PM
Here's what I was able to come up with on Unity 5.6.1
public class SetLineRendererSortingLayer : MonoBehaviour
{
public LineRenderer lr;
public string SortingLayer;
public int OrderInLayer;
void Awake()
{
lr = this.GetComponent<LineRenderer>();
}
void Start()
{
lr.sortingLayerName = SortingLayer;
lr.sortingOrder = OrderInLayer;
}
}
Reading more about Unity's Sorting Layers made for a simple solution. If you're unsure how to utilize the script above check out the README in the repository my solution is stored in.
Your answer
Follow this Question
Related Questions
Sprite frame by frame rotation 1 Answer
Sprite.Create is not working 1 Answer
(noob) 2D sprite jagged edges as smaller? 1 Answer
Rotating a sprite distorts it? 0 Answers
SpriteRenderer change order in layer in edit mod via script 1 Answer