- Home /
A lot of static objects affects the performance
I need to put a lot of objects (Max of 875) in my game via instantiating gameobjects from a prefab at runtime.
for(int r=0; r<rows; r++)
{
for(int c=0; c<columns; c++)
{
GameObject newBlock = Instantiate(Resources.Load("Block")) as GameObject;
}
}
This happens only one time, in the beginning of the game.
Given the created blocks have a mesh renderer, a shader of a texture (not necessarily high quality), a rigidbody. BUT they are constant during the game.
What options do I have to increase the fps and so to increase the performance?
You can combine them together using a mesh combining utility or by using https://docs.unity3d.com/Documentation/ScriptReference/$$anonymous$$esh.Combine$$anonymous$$eshes.html - this requires that they have the same material. $$anonymous$$ore complex combiners could create a texture atlas for you.
@whydoidoit Yes they are of the same material. Thanks for your answer but I have two questions: 1-do they have to be adjacent (beside each other with no empty spaces)? 2-can I destroy a block within that mesh combiner? Thanks.
They do not have to be adjacent - you can only remove them by modifying the mesh.
Your answer
Follow this Question
Related Questions
Can the Cull option in shader improve perfomances ? 2 Answers
Performance issues on HDRP 0 Answers
Bad performance on Android 0 Answers
Updating Unity Caused Severe Drop in FPS 1 Answer
Why CPU waits for GPU when there is not much work on GPU? 0 Answers