Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question How do I prevent increasing level numbers lead to increase build size?

Discussion in 'General Graphics' started by mfatihbarut, Sep 2, 2021.

  1. mfatihbarut

    mfatihbarut

    Joined:
    Apr 11, 2018
    Posts:
    1,059
    Hi all,
    I have a mobile game that looks like Plants vs zombies.
    I only have a house and garden.
    But on each level, just barriers and monsters are changing.
    Normally I thought I would make the levels separate (even though they have the same template)
    It would be much easier to organize for me.

    However, I decided to test and copied the same level 85 times. And tried to compile it.
    The compile-time looks like 30 sec for each level which means for over 100 levels my compile time will be over an hour which is really not nice.
    Besides Build size seems to get 5MB or more for each level. And that means I am adding 500mb of unnecessary data to my compiled project. Which is also not nice for a mobile game.

    What do you think. What am I doing wrong, how can I overcome this problem?
    Besides writing a level manager and creating a (kinda) database for each level's barriers and monsters and their spawn positions and times etc.
    Which looks very scary to me because I have never done before and it means "Lots of virtual connection wire in my mind") that I have to remember...You know...
     
  2. kdgalla

    kdgalla

    Joined:
    Mar 15, 2013
    Posts:
    4,613
    Have you tried making a prefab for each level?
     
  3. mfatihbarut

    mfatihbarut

    Joined:
    Apr 11, 2018
    Posts:
    1,059
    Thanks, a good point I didn't do that...
     
  4. kdgalla

    kdgalla

    Joined:
    Mar 15, 2013
    Posts:
    4,613
    I'm not sure what overhead prefabs entail, but you could test it the same way as you did with multiple scenes.
     
  5. SoftwareGeezers

    SoftwareGeezers

    Joined:
    Jun 22, 2013
    Posts:
    902
    If you are repeating the same assets (monsters, plants, backgrounds), then the typical approach would be to just record their positions and create your levels by instantiating the objects at the required positions when you start a new level.
     
  6. mfatihbarut

    mfatihbarut

    Joined:
    Apr 11, 2018
    Posts:
    1,059
    yeah I also realized that and it really can speed up my process