- Home /
Particle System Sorting Layer Refuses To Be Assigned
Hello. I've got a particle system on an object in a 2D game, and so I need to set the sorting layer of the system to the right layer. The script below should do that. Except that it doesn't. Thanks for help in advance.
using UnityEngine;
using System.Collections;
public class BlueOrbParticleScript : MonoBehaviour {
void Start () {
GetComponent<ParticleSystem>().renderer.sortingLayerName = "Layer2";
}
}
Oh, and I've already checked and double-checked that "Layer2" is the correct name for the layer.
Have you checked the script is definitely attached to the right component? The same component that has the particle system attached to it?
Answer by rv-ravi · May 28, 2014 at 09:40 AM
void Start () {
GetComponent<ParticleSystem>().renderer.sortingLayerName = "Layer2";
GetComponent<ParticleSystem>().renderer.sortingOrder = 2;
}
Also set sorting order to the particle system
Sorry for getting back to you so late. I already have the background assigned to a lower layer, so this shouldn't change anything. I checked just in case, but unfortunately, your suggestion didn't work.
Then change sorting order as your need to positive/negative If you want particle behind Layer2, then set negative, else positive Check this, it might be worked