- Home /
Can I force Shuriken to recalculate its bounds properly after using SetParticles() ?
There is an old problem with Shuriken where the whole particle system gets culled when its center is off screen. There are also some suggested workarounds to be found, but none of them work for me. First let me clarify that there seems to be two possible causes for this problem. One has to do with scaling, and I've read some people who fixed it by setting the scale of their Shuriken transform to (1,1,1), others who have added a sub-emitter and got it to work. In my case, I believe the problem is a different one, and the above fixes didn't work. I tried to pinpoint the problem, and here is what I found:
When using SetParticles() to set all the sizes, positions, etc from a script, the renderer.bounds property has Extends(0,0,0) afterwards, which explains why the whole system will be culled when its center is out of view. A standard, non-scripted Shuriken will recalculate its bounds constantly while playing and will account for all the individual particles, thus still rendering when any are in view.
Now I wonder if anyone knows how exactly these bounds are calculated - maybe I need to script-set some other property of the particles or the system so it can calculate the bounds correctly? Or maybe I can force the Shuriken or its renderer to recalculate the bounds after calling SetParticles()?
[edit] If there is a way to call ParticleSystem.Play() without overwriting my script-set particle data, I assume that might help as well, as I believe the reason it does not update its bounds might be that it has to be stopped or paused in order for the scripted data to take effect.
[edit] I also tried giving the transform a mesh renderer and -filter in hopes there would be one bounding box per transform, but that didn't do it either. So there seems to be no way to influence renderer bounds and shuriken culling at all? Can someone confirm that?
[edit] I just read, in an answer to this post, that the particle system "uses a single mesh". Is there a way to access that mesh? When/how is it created? I'm sorry if I ask too many questions in one post, but an answer to any of them would enable me to at least try some more things to get it to work. So they're all pointing to the same problem, I hope that's fine. If there's any way to improve my question please let me know - I've been fighting this problem on and off for years now.
Answer by morbidcamel · Oct 08, 2014 at 06:10 AM
I have the same problem. If I leave the particle system in the scene for some reason it works. If I instantiate it or scale the particles themselves (not the transform) the .SetParticles method does not recalc its bounds and its driving me nuts. I am using shuriken specific functionality like collisions (which is supposed to disable frustrum culling but does not!)
I have logged multiple bugs and even added a few suggestions http://feedback.unity3d.com/suggestions/please-add-the-ability-to-disable-automatic-culling-on-particle-systems
The bug has been known for a while, I think when I first encountered it in 2012, it was already filed - at least some form of it.
Answer by coding_crow · Oct 05, 2014 at 01:00 PM
Ok so for anyone who comes across this thread and has similiar problems: I just tested using legacy particles instead, as described here, and from the first look it seems to work nicely - I can pan around the particle I created with the emitter way out off screen and it still shows, so if you don't need any shuriken-specific functionality, this is a workaround that helps without recalculating every particle in world space, which I did before.
Your answer
Follow this Question
Related Questions
Changing sub emitter via script? 1 Answer
Accessing Shuriken particle system values through a script in C# 3 Answers
How do I create a Shuriken moving particle system? 0 Answers
Scripting Shuriken 1 Answer