C# coding errors PLEASE HELP!!!,I need some help with these c#sharp errors
So I used this code from this link (http://answers.unity3d.com/questions/577288/particle-system-rendering-behind-sprites.html) to write a script to add my particle effect to a sort layer. I soon got these errors.
1: Assets/ParticleSortLayerScript.cs(16,6): error CS0116: A namespace can only contain types and namespace declarations
2: ArgumentException: Illegal characters in path. System.IO.Path.Combine (System.String path1, System.String path2) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.IO/Path.cs:127)
My code is this below:
using UnityEngine;
using System.Collections;
public class ParticleSortLayerScript1 : MonoBehaviour {
// Use this for initialization
void Start () {
particleSystem.renderer.sortingLayerName = "Fog";
}
}
Please help me, this is my first time with scripts and making a game in general.
,So I made a script from this question (http://answers.unity3d.com/questions/577288/particle-system-rendering-behind-sprites.html) in order to have this fog particle effect to render in front of other layers. I made a layer in front of the other ones called "fog".
I got these two errors after I made the script for the particle effect.
1: Assets/ParticleSortLayerScript.cs(16,6): error CS0116: A namespace can only contain types and namespace declarations
2: ArgumentException: Illegal characters in path. System.IO.Path.Combine (System.String path1, System.String path2) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.IO/Path.cs:127)
This is my code below:
using UnityEngine;
using System.Collections;
public class ParticleSortLayerScript1 : MonoBehaviour {
// Use this for initialization
void Start () {
particleSystem.renderer.sortingLayerName = "Fog";
}
}
Please help me! This is my first time making a 2D game on Unity so I'm obviously very new to this.
Answer by ifurkend · May 17, 2017 at 07:26 AM
Unity's particle system scripting has undergone major changes since 5.3. In your particular case, you need to get component of "ParticleSystemRenderer" instead of "ParticleSystem" first before using its function, I concur it's counter-intuitive.
Hmm, I was using an old version of Unity so I'm going to switch my project over there.
Your answer
Follow this Question
Related Questions
Update and Get PlayerPrefs during runtime? 0 Answers
Reversing the process 0 Answers
My Raycast won't work at all ?? (C# Windows) 1 Answer
how do i fix this error? 0 Answers