Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • 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 /
This post has been wikified, any user with enough reputation can edit it.
avatar image
1
Question by Scud · Feb 04, 2013 at 05:36 PM · instantiateframeratemain thread

How to improve performance with a lot of same prefab?

To create a level geometry, I'm Instantiate prefab 4000 times at the start(). So my level geometry created, when level starts.


With that having very low framerate, although there nothing else in the level right now. The problem is Main thread, which keeps at ~330ms, although Renderer take just 2~4ms. Draw calls - 12, saved by batching - 2000. All other statistics at minimum or very low. What should I do to lower Main thread?

Comment
Add comment · Show 5
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 Wolfram · Feb 04, 2013 at 08:22 PM 0
Share

How many scripts are in your prefab, and which ones?

avatar image Wolfram · Feb 05, 2013 at 03:34 PM 0
Share

Please answer my question, it is vital information.

Also, is your "fab" object you assigned in the Inspector...

  • an object in your scene?

  • a model from the Projects tab?

  • a prefab from the Projects tab?

avatar image Scud · Feb 05, 2013 at 03:56 PM 0
Share

prefab, which I'm trying to instantiate, has no scripts. In scene just one script, it's "creation" script, which I posted below.

$$anonymous$$y "fab" is a prefab from project tab.

avatar image Scud · Feb 05, 2013 at 04:08 PM 0
Share

Thank you, found the case of my problem. That was the "Avatar" part of imported model. Switched "animation type" to "none" in inspector->import setting->Rig->animation type Wonder, why it's switched on by default for the model without animation. Hope this will be helpful for someone else. can you please submit answer tomy question, so I can mark it as answered?

avatar image Wolfram · Feb 05, 2013 at 04:11 PM 0
Share

I converted it to an answer. Glad you solved your problem!

2 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by Wolfram · Feb 05, 2013 at 03:59 PM

Then you need to find out what's special about that prefab. How does it differ from the actual model? Is it composed of several individual models? Other prefabs? Do the models have animations? Are there Colliders in the prefab?

(please respond to all questions, all have significance)

Comment
Add comment · Show 2 · Share
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 Scud · Feb 05, 2013 at 04:16 PM 1
Share

Yes, the problem was in model's animation. Avatar is imported for all models by default, and not needed to simple static models. Switched "animation type" to "none" in inspector->import setting->Rig->animation type. Solved.

avatar image Wolfram · Feb 05, 2013 at 04:47 PM 0
Share

$$anonymous$$udos to you. I wished everyone new to this site would care as much as you do about readability, and benefits for future readers! :o)

avatar image
0

Answer by robertbu · Feb 04, 2013 at 05:47 PM

A couple of things to look into. Turning off the renderer on any object that are not currently being used will help. If some of the objects are static with respect to each other you can combine meshes. There are a couple of example scripts that are available when you install the standard asset package: in the "Standard Assets/Scripts/Utility Scripts" folder you will find CombineChildren and MeshCombineUtility scripts.

Comment
Add comment · Show 5 · Share
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 Scud · Feb 04, 2013 at 07:50 PM 0
Share

I attached CombineChildren script to parent of my prefabs, but it results only in prefabs no more visible. $$anonymous$$ain thread is still ~300ms

avatar image robertbu · Feb 04, 2013 at 07:56 PM 0
Share

Do you have pro (and therefore run the profiler)? It sounds like the issues are not with the draw code, but something else.

avatar image Scud · Feb 05, 2013 at 03:31 PM 0
Share

No, I can't run profiler, but the situation is easily repeatebly with imported objects that you put in fab variable (my have 24 faces each). Can't create the same effect with Unity's GameObject->create other->Sphere, for example. So it has something to do with importing(from $$anonymous$$aya, in my case)

 var fab : GameObject;
 
 function Start () {
 for (var i=0; i<4000; i++){Instantiate (fab, transform.position, transform.rotation);}
 }

With Spheres I have $$anonymous$$ain Thread - 50 ms, Renderer - 20 ms, and this result seems normal.

avatar image Wolfram · Feb 05, 2013 at 04:00 PM 0
Share

You just instantiate them, nothing else? (especially transfor$$anonymous$$g them around via Animation or other scripts?)

avatar image Hamzeh Soboh · Feb 24, 2014 at 04:29 PM 0
Share

@Wolfram I do what you said, a lot of static objects, without animating any. What do you see?

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.

Follow this Question

Answers Answers and Comments

11 People are following this question.

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

Related Questions

Huge Framerate Drop 0 Answers

Checking if object intersects? 1 Answer

Performance issues with grid based terrain 2 Answers

unity locks up when loading prefabs 1 Answer

Retina specific framerate drop on specific function 1 Answer


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