Not sure if this is a Unity specific or tk2d specific question.
I noticed I have more draw calls than expected, so I started to investigate.
Bottom line, it seems that when instantiated objects have a different Z position, the result is a higher draw call count than if not.
The experiment is simple:
I instantiate object 1, followed by instantiation of object 2, then 1 then 2 again.
Each object uses a different sprite collection.
The result: With the same Z, 2 draw calls, with different Z, 4 draw calls.
Also, when instantiating at a different order (1 1 2 2) the result is 2 draw calls regardless of the Z.
Screenshot:Code:using UnityEngine;
using System.Collections;
public class DrawCallTester : MonoBehaviour {
// Attach two sprites that use a different collection
public GameObject proto1;
public GameObject proto2;
void Start() {
// Result:
// When Z is the same, success ( 2 draw calls )
// When Z is different, failure ( 4 draw calls )
// When order is 1 1 2 2, success ( 2 draw calls )
int x = 1;
Instantiate( proto1, new Vector3( x++*100, 300, x*10 ), Quaternion.identity );
Instantiate( proto2, new Vector3( x++*100, 300, x*10 ), Quaternion.identity );
Instantiate( proto1, new Vector3( x++*100, 300, x*10 ), Quaternion.identity );
Instantiate( proto2, new Vector3( x++*100, 300, x*10 ), Quaternion.identity );
}
}
Is this to be expected?
Is there anything I can do about it?
Thanks in advance.