LooMeenin
LooMeenin

Reputation: 818

Why am I getting 30 draw calls from an empty GameObject in my scene in Unity3D?

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.

Upvotes: 4

Views: 3078

Answers (1)

Greg Lukosek
Greg Lukosek

Reputation: 1792

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/

Upvotes: 1

Related Questions