4
votes

First of all, I'm talking about SetPass calls, which I understand are draw calls.

I have an empty GameObject that I use as a Camera target in my game. I've positioned it above my character and when it reaches x height the camera moves up.

With the Camera target enabled, I get about 60 SetPass calls. When I disable it, I get around 30.

Why does this simple object produce so many SetPass calls?

Here's the screenshot with empty GameObject enabled:

enter image description here

Here's the screenshot without GameObject enabled:

enter image description here

Here is the empty GameObject:

enter image description here

This is where I reference the empty GameObject(cameraTarget):

void FixedUpdate(){

if (cameraTarget != null){
    if (cameraTarget.transform.position.y > thisTransform.position.y) {
        thisTransform.position = new Vector3 (0, Mathf.SmoothDamp (thisTransform.position.y, cameraTarget.transform.position.y, ref velocity.y, smoothTime), 0); 
    }
}

}

When I disable the empty GameObject during gameplay my game runs fine and the camera still follows the empty GameObject even though it's disabled and I'm getting way less SetPass calls... weird.

EDIT:

The label icon attached to my Empty GameObject was causing the increase in draw calls:

enter image description here

EDIT:

I disabled the "Gizmos" in the Game window and it has removed draw calls across all of my scenes. I guess it's only an issue when running a game in the Editor.

1
this doesn't look to me like it's an empty object.... Your first example shows 736 Triangles, 1.1k Vertices; The second shows 512 Triangles, 802 Vertices. Clearly there is something else in the scene.Claies
@Claies - The GameObject is nested inside of my characterLooMeenin
right, that still doesn't explain where the extra triangles/vertices are at, but those are surely what is causing more SetPass calls.Claies
I updated my question to include a picture of the empty GameObject with just a Transform. This is the object I am disabling/enabling.LooMeenin
Is there any dynamic mesh creation code in your project? Is there any possibility that the Empty gameobject would be assigned to or used by any of dynamic mesh creation codes?Can Baycay

1 Answers

1
votes

Unity 5 have a neat feature called Frame Debugger. You can capture the frame and see what is going on exactly, More informations here http://blogs.unity3d.com/2014/07/29/frame-debugger-in-unity-5-0/