- Home /
Question by
Lewis G 0400 · Mar 01, 2014 at 11:07 PM ·
c#compile-error
Compile issue
I wrote a script for toggling a particle system on and off. When I tried adding it to an object it said it wasnt compiled but when I compiled it it gave me errors.
compile error.png
(37.6 kB)
Comment
Answer by knunery · Mar 01, 2014 at 11:54 PM
Your problem is on line 8. You cannot access the gameObject
yet.
In short I think the appropriate Unity way of doing this would be to add the following function and remove the initialization on line 8. You still need to declare the member variable on line 8. Make sense?
void Start()
{
particlesystem = gameObject.GetComponent<ParticleSystem>();
}
Your answer
