• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by jonesa01 · May 28, 2012 at 05:21 PM · crashprefabs

Unity Crashes with too many prefabs

Hello,

I am developing a game in unity which involves me making a terrain out of blocks and other objects, however if I ever make the game over around 500x500 which involves instansiating around 250,000 prefabs Unity crashes. If I do 500x500 and instansiate different prefabs in a differnt loop directly after this it works fine.

Is there anyway to stop this from happening or is there a limit to the number of prefabs?

Thanks,

Adam

Comment
Add comment · Show 10
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image You! · May 28, 2012 at 05:43 PM 0
Share

Are you instantiating all of these through scripting? If you are, that would cause the crash, and you may want some of these objects put into the scene manually.

avatar image jonesa01 · May 28, 2012 at 06:00 PM 0
Share

I am because the terrain is randomly generated at game load so there was no option to put them in manually.

avatar image hijinxbassist · May 28, 2012 at 06:06 PM 0
Share

Are you storing the prefabs in memory, like adding them into an array? $$anonymous$$ight be memory related. Can you see all the prefabs at a given time? You might want to remove prefabs as you go to keep it clean

avatar image You! · May 28, 2012 at 06:09 PM 0
Share

Fortunately, you do have an option. If you have a world that large, you obviously will not be able to see all of it at once, even if all parts are instantiated at start up. You can have some of them instantiated right away, and others created when within a certain range of the tile (you can create empty gameobjects to serve as the center points of each tile).

avatar image jonesa01 · May 28, 2012 at 06:28 PM 0
Share

I like the idea of adding them as I go, however I have a $$anonymous$$i-map which shows the overview of the whole world (using a second camera) I am not sure how to go about this with setting the prefabs as they are required by the camera.

avatar image You! · May 28, 2012 at 07:40 PM 0
Share

Since the camera only renders what it sees (within a certain range), you can make sure that the parts are rendered before it is seen by the camera. If the camera currently covers the whole play area, just have it cover a smaller area (move it in closer).

avatar image whydoidoit · May 28, 2012 at 07:44 PM 1
Share

I suggest you have the $$anonymous$$i map look at something else that's smaller - that's going to be a lot of drawing for a map - potentially very slow. As you are procedurally creating your world could you also procedurally create something for the $$anonymous$$imap?

avatar image You! · May 28, 2012 at 07:59 PM 0
Share

Great idea, as always, @whydoidoit.

avatar image jonesa01 · May 29, 2012 at 01:38 PM 1
Share

Right I think I have solved the problem with the $$anonymous$$imap. I have created another scene which has a terrain (fixed size), I will then instansiate cubes to act as the models (to scale). Then positioned a camera directly looking down on it and set the Y value to be negative so the terrain will be underneath everything else. I then load the $$anonymous$$imap scene by using Application.LoadLevelAdditive. This means I will have exactly what I wanted a 3d landscape which will render as required and a low resolution 2d $$anonymous$$imap.

avatar image You! · Jun 05, 2012 at 06:48 AM 0
Share

...I know it's been a while, and the question has been answered, so why don't @whydoidoit or @jonesa01 answer the question? I know the two of you did most of the problem solving on this one, so one of you deserves the credit. Who's going for it?

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

7 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

A node in a childnode? 1 Answer

Prefabs Empty After Crash 2 Answers

Unity crashes when executing a script onMouseDown 1 Answer

Unity web Player 0 Answers

StreamReader in while loop stops/freezes unity 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges