- Home /
Trouble with destroying a particle.
unity says:
"No MonoBehaviour scripts in the file, or their names do not match the file name" i cannot add as a component to my game object.
public class DestroyFinishedParticle : MonoBehaviour {
private ParticleSystem thisParticleSystem;
// Use this for initialization
void Start()
{
thisParticleSystem = GetComponent<ParticleSystem>();
}
// Update is called once per frame
void Update () {
if (thisParticleSystem.isPlaying)
return;
Destroy(gameObject);
}
}
Is the name of your script file different then the name of your class, which is "DestroyFinishedParticle"?
no, they're the same. visual studio just took out the spaces.
checked the manual on monobehaviour, still at a loss
Answer by TheSOULDev · Aug 16, 2017 at 02:14 AM
Re-add the script or remove the script, create a new script and copy paste the functional code. Perhaps you tried to compile with an error and you're not getting it now, so your script isn't actually getting compiled. The solution is to add an error deliberately and then try to build, but the sure way to fix it is by re-adding or copy pasting the script into a newly made source file.