Image and RawImage with an alpha of 0 still produce 1 draw call.

Hi,

If you change the color of an image of of a rawimage and set its alpha to 0, the editor still report 1 draw call for it.

I haven’t tested it at runtime.

Why would we want Unity to waste CPU cycles checking for something like that? Especially when it’s floating point so you’d have to check if it’s “approximately” zero. If you want it to not draw, just disable the component.

I prefer to loose “CPU cycles” than Fillrate drawing invisible stuff for nothing. If alpha is a property it is easy to check only when its modified if its value is zero and automatically disable the component. Also a DrawCall is way more expensive than a value check lol …

I don’t understand your point of view, there is no interest to do it by ourself and to think “oh wait i put the alpha to 0, don’t forget to turn off the renderer”

How are you setting the alpha to 0. There are two ‘alphas’ that can be set:

  • Alpha on the Image component (changes the per vert multiplicative color)

  • Setting this to 0 will still generate the verts / batch.

  • Alpha on the CanvasRenderer (changes the renderers multiplicative color)

  • Setting this to 0 will skip the rendering of the batch.

1 Like

Ah ok I didn’t see the alpha on the canvas renderer.

Hi,
I’m having the same problem but I could not solve. I’m using Unity 4.6.0b21.
My scene hierarchy:

  • Canvas
    • Scene ( Panel )
    • Dialog xxxxx ( Panel, Canvas Group:Alpha 0, Dialog.cs )
    • Dialog xxxxx ( Panel, Canvas Group:Alpha 0, Dialog.cs )

I’m trying to reduce draw call because there are many ‘Dialogs’ in some scenes, but even using the code below Draw Call count doesn’t change.
How could I solve this without disabling GameObjects?

Dialog.cs

void Awake()
{
    var canvas = GetComponent<CanvasGroup>();
    var renderer = GetComponent<CanvasRenderer>();

    renderer.SetAlpha(canvas.alpha);
}

Thank you!