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 /
avatar image
0
Question by Matt 15 · Jan 17, 2011 at 04:25 PM · instantiatefor-loopdrawcalls

each instantiation getting it's own draw call?

Here is an example of draw calls skyrocketing when i try to instantiate a particle prefab on items in the scene that have a value set to true. Shouldn't all the instantiated particle prefabs be on the same draw call? or is it that it get's it's own because they don't happen at the exact same time? (given the loop i run through) any tips are greatly appreciated!

var startBoardExplosionAsset : GameObject; //linked through the inspector

itemsArray = GameObject.FindGameObjectsWithTag("item");

for (currentItem in itemsArray){ var currentScript : touchingThreeScore = (currentItem.GetComponent(touchingThreeScore) as touchingThreeScore);

         if(currentScript.worthPoints == true){
             var startBoardExplosion : GameObject = (Instantiate(startBoardExplosionAsset, currentItem.transform.position, currentItem.transform.rotation) as GameObject);           
         }
     }

//where touchingThreeScore is the name of the script with the boolean 'worthPoints' var is

Comment
Add comment
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

1 Reply

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

Answer by Eric5h5 · Jan 17, 2011 at 06:38 PM

All separate objects add an additional draw call (or more, depending on rendering mode). Some objects can be combined using static or dynamic batching, depending on certain conditions, but particle systems will never be combined.

(By the way, you can make shorter code by changing

var currentScript : touchingThreeScore = (currentItem.GetComponent(touchingThreeScore) as touchingThreeScore);

to

var currentScript = currentItem.GetComponent.<touchingThreeScore>();

You can also change

var startBoardExplosion : GameObject = (Instantiate(startBoardExplosionAsset, currentItem.transform.position, currentItem.transform.rotation) as GameObject);

to

Instantiate(startBoardExplosionAsset, currentItem.transform.position, currentItem.transform.rotation);

since you're apparently not using the startBoardExplosion variable for anything.)

Comment
Add comment · 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

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

No one has followed this question yet.

Related Questions

Instantiate object in for loop with array 2 Answers

How can I naming each instantiated object in "for" loop ? 1 Answer

Excessive VBOs and no batching while instantiating prefabs 0 Answers

Order of instantiated objects 0 Answers

how can i draw many (1000+) sprites 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