private void FillAllDrawCalls()
{
for (int i = 0; i < this.drawCalls.get_Count(); i++)
{
UIDrawCall.Destroy(this.drawCalls.get_Item(i));
}
this.drawCalls.Clear();
Material material = null;
Texture texture = null;
Shader shader = null;
UIDrawCall uIDrawCall = null;
int num = 0;
if (this.mSortWidgets)
{
this.SortWidgets();
}
for (int j = 0; j < this.widgets.get_Count(); j++)
{
UIWidget uIWidget = this.widgets.get_Item(j);
if (uIWidget.isVisible && uIWidget.hasVertices)
{
Material material2 = uIWidget.material;
Texture mainTexture = uIWidget.mainTexture;
Shader shader2 = uIWidget.shader;
if (material != material2 || texture != mainTexture || shader != shader2)
{
if (uIDrawCall != null && uIDrawCall.verts.size != 0)
{
this.drawCalls.Add(uIDrawCall);
uIDrawCall.UpdateGeometry(num);
uIDrawCall.onRender = this.mOnRender;
this.mOnRender = null;
num = 0;
uIDrawCall = null;
}
material = material2;
texture = mainTexture;
shader = shader2;
}
if (material != null || shader != null || texture != null)
{
if (uIDrawCall == null)
{
uIDrawCall = UIDrawCall.Create(this, material, texture, shader);
uIDrawCall.depthStart = uIWidget.depth;
uIDrawCall.depthEnd = uIDrawCall.depthStart;
uIDrawCall.panel = this;
}
else
{
int depth = uIWidget.depth;
if (depth < uIDrawCall.depthStart)
{
uIDrawCall.depthStart = depth;
}
if (depth > uIDrawCall.depthEnd)
{
uIDrawCall.depthEnd = depth;
}
}
uIWidget.drawCall = uIDrawCall;
num++;
if (this.generateNormals)
{
uIWidget.WriteToBuffers(uIDrawCall.verts, uIDrawCall.uvs, uIDrawCall.cols, uIDrawCall.norms, uIDrawCall.tans);
}
else
{
uIWidget.WriteToBuffers(uIDrawCall.verts, uIDrawCall.uvs, uIDrawCall.cols, null, null);
}
if (uIWidget.mOnRender != null)
{
if (this.mOnRender == null)
{
this.mOnRender = uIWidget.mOnRender;
}
else
{
this.mOnRender = (UIDrawCall.OnRenderCallback)Delegate.Combine(this.mOnRender, uIWidget.mOnRender);
}
}
}
}
else
{
uIWidget.drawCall = null;
}
}
if (uIDrawCall != null && uIDrawCall.verts.size != 0)
{
this.drawCalls.Add(uIDrawCall);
uIDrawCall.UpdateGeometry(num);
uIDrawCall.onRender = this.mOnRender;
this.mOnRender = null;
}
}