- Home /
Bring Halo Effect to Specific Layer in 2D Game
I'm just going to start off with saying: I have no idea what I am doing at the moment.
I am working in 2D. I have a particle effect with a Halo effect added to it. I cannot get the Halo effect to render in front of the sprites. I used a script to get the particle effect up front, but I can't figure out how to do it with the Halo effect. Here's the script.
using UnityEngine;
using System.Collections;
public class SpecialEffectsLayer : MonoBehaviour {
private Component halo;
// Use this for initialization
void Start () {
halo=gameObject.GetComponent("Halo");
halo.renderer.sortingLayerName = "2nd Foreground";
}
}
I'm sure I'm butchering the syntax. I saw a few different questions on here involving referencing the Halo, but they all have to do with enabling and disabling it.
Here is an image of what it looks like currently (as well as the Inspector). You can see the particle effect is in front, but the Halo is not.
Any help would be greatly appreciated!
Answer by kbumpious · Apr 09, 2015 at 10:17 AM
Did anyone ever figure this out? I have (Unity 5):
This will compile and run but the halo is still behind everything. Im working in 2D.
private Component halo;
// Use this for initialization
void Start () {
halo = gameObject.GetComponent("Halo");
halo.GetComponent<Renderer>().sortingLayerName = "Dolphin";
halo.GetComponent<Renderer>().sortingOrder = 0;
}
@aegodbold, @kbumpious did you ever figure out a solution? I would also like to know if there is a solution to this as I am encountering the same issue. No matter which sorting layer the Halo effect is on, it will not render in front of sprites. I see the same questions asked in two other threads with no answer as well:
http://forum.unity3d.com/threads/halo-component-doesnt-work-when-drawn-over-sprites.254892 http://answers.unity3d.com/questions/757589/how-can-i-create-a-halo-effect-on-a-2d-sprite.html
Answer by MarkD · Apr 09, 2015 at 11:24 AM
You can attach the halo as a separate component or creatie tour own script to place a 2d texture on te location of the light. Then move this texture to a higher draw layer.
Answer by Beastman632 · Feb 12, 2018 at 10:52 PM
It seems the shader the Sprites - Default material uses causes this behaviour. Create your own material and set its rendering mode to Cutout and shader to standard. This will allow halos to show in front of your sprites.
Answer by NGGProgress · Oct 09, 2019 at 11:25 AM
I fixed this problem by creating new material for the sprite behind which the halo was hidding. The new material was: Shader: Mobile/Particles/Alpha Blended, Render Queue: AlphaTest - 2450. This material does not affect the quality of the sprite and makes the halo gameobject visible. I am using Unity 2018.2.20f1.
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
parallax on x, But how on the y as well? [Solved] 1 Answer
A hole in ground after explosion [2D] 0 Answers
C# UI list item drag onto 2d sprite in world space? 1 Answer