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 gwarsh41 · Jul 15, 2012 at 03:07 PM · androidtexturemobileoptimization

Changing objects texture causes high draw call count!

Part of the game I am working on is avoiding bombs. If you hit a bomb it will "burn" everything around it. I am doing the burn by changing the texture atlas out for a burnt style atlas. The problem is that each time the texture swap happens, it seems to add 3-15 draw calls pending on how many objects are being hit. The bomb instantiates graphic for the explosion. This graphic is what triggers the texture switch. Here is the code on the graphic.

     #pragma strict
 

var object : GameObject[]; object = GameObject.FindGameObjectsWithTag("pig"); var texture : Texture; var test = false;

function Awake () { //destroy after .1 seconds Destroy(gameObject, .1); test = true;

} //look at the camera function Update(){

transform.LookAt(transform.position + Camera.main.transform.rotation Vector3.down,Camera.main.transform.rotation Vector3.back);

if(test == true){ test = false; for (var obj: GameObject in object){ obj.renderer.material.mainTexture = texture; } }

}

With near max objects on screen I am only at 2 draw calls. When I detonate a bomb it jumps to 15 instantly. The draw calls go down as the items destroy themselves after being hit by the bomb.

I cannot figure out why swapping the textures would cause such a problem. Would it be a better idea to have the explosion graphic change a variable on the objects hit by the explosion, then that variable controls the texture change? Then each object hit changes its own texture, instead of one object changing +10 textures.

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
0

Answer by whydoidoit · Jul 15, 2012 at 03:10 PM

Your problem is that as soon as your set the texture you are getting a copy of the material for each of the objects - none of them batch after that as they all have different materials.

I suggest you have a burned material which you set on the objects rather than changing the texture, this material would already have it. Then maybe set the sharedMaterial (though I can't quite remember whether you need to do that).

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Setting Material Textures at runtime for the rest of the game 0 Answers

How to handle many highly detailed models in a mobile device ? 1 Answer

Android water texture 1 Answer

Is using ragdolls practical on mobile devices? 1 Answer

Blue looks like teal on mobile? 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