- Home /
Merging together all GameObjects of an Array?
Having an array made of GameObjects, how do i merge together all the elements of it to obtain a single GameObject? And then perhaps assign it a name? I hope this would reduce drawcalls in my scene but i'm somehow stuck with this task... I use javascript.
Why don't you do it in the editor? Or are you instantiating these objects at runtime?
EDIT: I meant modelling application
and what do you mean with 'merge'? what are you trying to do here?
Ins$$anonymous$$d of parenting the objects, just use the "foreach" loop if you arent already. Though, I guess in Javascript you have to use a for-loop!
I'm not sure what you mean by merge, but it sounds like you're trying to reduce the number of Draw calls by combining meshes.... If that's the case, unless you combine your meshes in a modelling program, it's going to have the same number of faces and require the same number of draw calls, even its one gameobject ins$$anonymous$$d of many.
Answer by MakeCodeNow · Mar 05, 2014 at 06:26 PM
If your goal is to reduce draw calls, you'll need to combine rendering primitives (i.e. meshes), not game objects. The Unity documentation has a lot of information about getting data out of and creating new Meshes. There's also very good info in the answers section here. Note that this is going to be time consuming, not something you knock out in an hour with a couple of for loops.
PS - Combining objects to minimize draw calls is exactly what static and dynamic batching are meant to do.
Your answer
Follow this Question
Related Questions
Which is better performance-wise? 1 Answer
Are .gameObject and .transform both using GetComponent() in the background? 1 Answer
New Object Pooling Problem 1 Answer
Optimize huge number of Destroy() calls (cannot use object pooling) 3 Answers
script optimization (choosing an object in game by click) 1 Answer