- Home /
Unity and the cost of nested game objects
This is my first question, I am a game developer for some years now, having worked with UDK, Android, and some other proprietary C++ engines. I feel like I am beginning to wrap my head around the unity way of doing things, but am a bit stalled converting my android tower defense game to unity.
What I am trying to accomplish
I need to store the information for my tower defense games Waves, in android I had a XML file that added Wave objects to a WaveManager. A Wave object contains a list of WaveConfigurations, each WaveConfiguration object has a Creep, the spawn count, delay between them, some other minor details.. you get the drift.
How I am attempting it in unity
The way I am trying to do this in unity, is I added a empty Waves object, under it I have a empty Wave01 object, under this I am planning on placing Creep objects that have a component which allows you to choose a creep Prefab, spawn count, delay etc.
I feel like this approach may have performance impacts however.
Does anyone have a suggestion on doing this Unity like? Is my original XML -> To object structure the best approach in Unity as well?
So in short I should look into XML Parsing and add that to the Start of a WaveManager to build the object represenation I am familiar with in android?
EDIT
Here's a visualization of what I was wanting to do:
I.E.
Waves -> Wave01 -> Creep01 -Creep Component (Transform (Creep Prefab)) -CreepSpellCastComponent -DoWhatYouWantComponent ...
Seemed like modifying and creating waves could be much easier, done visually. But maybe this isn't appropriate design for unity.
Answer by DaveA · Mar 20, 2012 at 10:12 PM
You can use one script (one object) to parse and store all your wave data. Gameobjects are generally best separate and parented if they are geometrically and hierarchically related, because each one has a Transform. Doesn't sound like this data would need that.
Thanks for your reply, I added a edit to better represent what I am trying to achieve, but maybe it just doesn't fit correctly. I could end up having 1000+ game objects for a single map. (10 creeps average across 100 levels).
Well I suppose you could do it that way. Also the Asset Store has some visual tools for doing stuff like this, it might be a way to go. I don't know the actual overhead for carrying around more game objects, just that they contain a Transform and some bookkeeping like all the fields you see on GameObject. So a bit of waste there. With machines today.... I wouldn't want to do it on $$anonymous$$obile. If you are working on an Editor script, that's different.
Your answer
![](https://koobas.hobune.stream/wayback/20220613065345im_/https://answers.unity.com/themes/thub/images/avi.jpg)