- Home /
DrawCall results are strange
I'm working on a mobile game and I am using a texture atlas. The problem is I had the beleif that using a texture atlas would mean 1 draw call for all textures but everytime I use part of the artlas my "DrawCalls" goes up by 2..... here's how I am calling it ...
GUI.BeginGroup(new Rect(0,0,Screen.width,Screen.height) );
foreach (GUIBit gb in SceneElements)
{
if (gb.Show)
{
if (gb.AtlasTextureNumber == 0)
Graphics.DrawTexture( new Rect(gb.x, gb.y, gb.width, gb.height), textureAtlas.texture, new Rect(textureAtlas.areas[gb.AtlasNumber]), 0, 0, 0, 0 );
if (gb.HasText)
{
GUI.Label(new Rect(gb.x, gb.y, gb.width, gb.height), gb.TextToShow, GuiStyles[gb.styleIndex]);
GuiStyles[gb.styleIndex].normal.textColor = Color.white;
}
}
}
GUI.EndGroup();
basically what I am doing here is loading in a texture atlas and then storing an array of points on the texture atlas these are the ... "textureAtlas.areas[gb.AtlasNumber]"
I am then storing an array opf "GUIBits" which store info such as which texture to use from "textureAtlas.areas[]" and where to display them on screen and a boolean for show or not so I can turn them on and off at run time.
So yeh, everytime I turn one on I am getting a +2 to the draw calls even though the texture is only added to my "TextureAtlas" class the once ?
Thank's for any help on this
Draw calls aren't only affected by the textures you're using... they're also affected by the shader type of the texture, and by how light is hitting it.
If you start an empty scene and add a point light and a plane, you'll have 2 draw calls. Change the plane to have a VertexLit material ins$$anonymous$$d of its default Diffuse, and now you'll only have 1.
So, what shaders are you using? What lights are hitting it?
That's the thing mate, I'm drawing them to the GUI .... They are gui elements ...
The piece of code I pasted is the entirety of my "onGui()" function inside my "GUI$$anonymous$$anager" which does all of this working out for me
You're right, I don't know why I missed that.
Well, I know that Unity's built-in GUI isn't particularly efficient, but I don't know any details. I've converted my answer to a comment in the hope that someone else will see this question as unanswered and will be able to provide an answer.
Your answer
Follow this Question
Related Questions
Texture atlases on iphone 3 Answers
Multiple Tiling Textures in the Same Material 1 Answer
Reducing drawcalls on texture atlas animation 0 Answers
Particle System Draw Calls 1 Answer
Draw Calls Not Reduced After Adding Texture Atlas. 0 Answers