- Home /
Stop batching at runtime? Still in memory?
During runtime, if you have an object and want to stop it from being batched, can you simply disable it? And if it was being batched previously, will it remain in memory if it is not actually being rendered once disabled? And then can you then re-enable it, and have it get batched again?
like gameObject.Find("someobject").static = false? or .static.enable = false? or just completely disabling the the object?
If I can do this, I would like to know if once batching for it is disabled, if the memory dumps it automatically, or will I have to do some sort of garbage collection?
i read the docs on batching and have looked into it different threads and such, but couldn't find anything about manipulating batching this way.
Another way to put it: Two objects, one hipoly one lowpoly, are in a LOD group. Both marked to statically batch. Is the non-visible object still getting batched? Is it still in VRA$$anonymous$$ memory?
Answer by whydoidoit · Aug 02, 2013 at 10:35 AM
I believe that static objects are batched the moment the level loads in the player - I don't think you can make an object marked static as visible or invisible after the fact due to this behaviour - it is already in the big static mesh.
Dynamic batching is well - Dynamic - so that does account for visibility.
It is certainly possible to write your own batching code that can know that things have changed and recalculate accordingly.
Perhaps make two copies of the scene, in one enable the high poly and in the other enable the low poly and then load the appropriate one?
Ok, so in an LOD group, an object would not dynamically batch if it is currently the unseen object?
I don't think two scene would work in my situation. As far as writing a batching code, that is probably beyond my coding skills, sadly.
Thanks for the reply :)
another thought: would putting a bunch of statically batched meshes into a group that is dynamically batched work? This would be good for open world, where I want to batch parts of the map at a time, but not all of it at once. $$anonymous$$now what I mean?
No that doesn't work - a magic big mesh gets created at the start of the level from all of the static objects that share a material etc.
The other problem with batching is the limitation on the number of vertices in the meshes. For Dynamic I think it's quite low on the source meshes - but I can't recall the exact figure...
crap, well that makes sense. I might take a stab at coding it. Any key unityscript code terms I should focus on? Thanks for the help!
I had a look at the static utility, combine. Seems like this is a way to manually batch. So this could be used during runtime, not just at the start of a game right? If so this should be fairly easy to code. Now I just have to figure out how to dump old batches from memory. link text
Your answer

Follow this Question
Related Questions
Mouse click to select and Isolate 0 Answers
Please Help!!! Enable/Disable Script!!! 3 Answers
random respawn and respawn delay 1 Answer