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 siddharth3322 · Mar 18, 2014 at 08:45 AM · spriterendererdrawcallsunity4.3

Reduce Draw Call for Sprite

I am working on side scrolling game so for that I want to define strategy for game objects.

I want to reduce draw call for game objects that are not in camera visibility either they are gone or not get turn to come in focus.

I have some working experience with AndEnginge in which I handle this situation in following manner.

         public void enable() {
         setVisible(true);
         setIgnoreUpdate(false);
         terrainBody.setActive(true);
     }
 
     public void disable() {
         setVisible(false);
         setIgnoreUpdate(true);
         terrainBody.setActive(false);
     }

I am pretty new to unity 2d game development so I want suggestion in this to improve performance of my game.

Also provide guidance for 3d objects if they come in same situation.

Comment
Add comment · Show 1
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 Scribe · Mar 18, 2014 at 10:01 AM 1
Share

Like @CodinRonin said the camera won't create a draw call if the sprite is not on camera however if the sprite has scripts with update functions then these will still be called every frame. So if you are doing a lot in update on a lot of sprites you may want to iterate through your list of sprites and disable them with someGameObject.SetActive(false) if they are a distance (up/down or right/left) from the camera.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by CodeElemental · Mar 18, 2014 at 08:57 AM

Unity cameras support what you want out-of-the box . It is called Frustum culling. (Objects that are not visible by the camera are not rendered = no draw calls)

Find out more in the documentation for camera . Look for the clip panes section.

Comment
Add comment · Show 4 · 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 siddharth3322 · Mar 18, 2014 at 09:15 AM 0
Share

As per my understanding, things which are in camera visibility are rendered. We have to set camera near and far clipping for performance benefit. Am right in this? There is no 2d and 3d different in this.

avatar image CodeElemental · Mar 18, 2014 at 09:45 AM 0
Share

Yes , the things displayed on the camera are rendered. You can specify which camera renders which game objects by specifying a layer to the gameobjects and a layermask to the camera's cullmask.

Additionally the near/far clip plane can restrict displaying/rendering also ( things "in front" of near plane , and the ones "behind" far plane are not rendered.

avatar image CodeElemental · Mar 18, 2014 at 09:55 AM 0
Share

Also , you can watch this unity official tutorial on cameras. It's pretty informative.

avatar image siddharth3322 · Mar 18, 2014 at 12:22 PM 0
Share

Thanks for all these replies. First I will look at them and reply back.

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

21 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Atlas size based on sprite 0 Answers

Sprite Rendering Cost Calculation 1 Answer

Jelly Object for 2D Game 2 Answers

Strachable Object Creation 0 Answers

Terrain generation 0 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