- Home /
How do I reduce resource cost of textured quads?
I feel that quads take up way more resources than they should, my game starts to lag with just 10,000 of them, but it's a block based game, so there is going to have to be a lot of quads everywhere to represent blocks sides and block tops and such. So how do I make these take up fewer resources? I thought Unity automatically culls textures that are not being seen by a camera, but if not, how do I do so? Thanks
just 10,000 of them
Yeah, that's a lot of GameObjects. Unity isn't designed to handle such amounts, they might even have colliders which taxes the system even more due to physics calculations. Also, it's not the number of vertices or presence of a texture that is the primary cause of slowdowns, it is the amount of seperate GameObjects. This kind of question pops up regularly, and the answer is always the same: Take a look at the $$anonymous$$esh class and search for tutorials and scripts on how to generetate meshes at runtime, and combine all those quads into chunked meshes. 10,000 quads have 40,000 vertices, which is still below the ~64,000 vertex limit of a mesh so you could even put all those quads into one single mesh, which results in one single GameObject.
Ah! Someone once told me that a GameObjects used almost no resources, I never thought that they would be the cause of all this lag. Yes, from looking at some forums about this sort of thing, it appears that most people counter this problem by using a mesh for a large number of blocks, although I've always been under the impression that a mesh was something that you'd spend several hours making in Blender, and not something created at runtime, I guess I've got some things to learn about meshes. Well, you have helped me solve my problem, so if you could post something about meshes as an answer then I could accept it.
Empty gameobjects don't take resources. Same is not the case when they are having components.
You don't need 10,000 at a time. Here is how you can optimize:
Use tiled sprites ins$$anonymous$$d of quad. If that is not possible then make sure the materials in all the quads are the same. This will help in batching.
If the tile is not moving then mark it as static. This will help in static batching of similar tiles at runtime.
Do not use collider on every tile. Ins$$anonymous$$d use another empty gameobject with just the collider on it for long grounds/surfaces.
Your answer
![](https://koobas.hobune.stream/wayback/20220612173354im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Assigning script-generated textures 0 Answers
Load texture and shaders at runtime on iPhone 2 Answers
My ios Project is too big!?what can i do? 1 Answer
Textured object appears transparent in a textured sphere with front culling 1 Answer
Make reference to the project texture file in the material field 1 Answer