Ok, so what I need is Viewport
’s
void set_canvas_cull_mask_bit(layer: int, enable: bool
)
…which allows individually toggling a level’s visibility.
But i find the doc hard to read. The method suggests setting a mask bit, but the parameter is named “layer
”. Also, given the below wording:
Set/clear individual bits on the rendering layer mask. This simplifies editing this Viewport's layers.
Doesn’t help to explain the enable
flag. My understanding of mask is that if I want layers 2 (Bit 1, value 2) and 3 (bit 2, value 4) to show, I could just send a single 6 is as a param, and this tells us we want layers 2 and 3 (values 2 + 4). Setting 0 would clear them all.
On testing it appears “level” is correct and the method is badly named. If I set (1, true) only my Layer 2 is shown (Bit 1, value 2).
It also doesn’t unset other levels, like I thought a mask would.
There is also no array input, so if I want to enable or disable multiple layers at once, I can’t, I have to individually set each to on or off.
Possible enhancement?
Anyway. the answer is to directly use the mask property
canvas_cull_mask
which semi-works as I would expect.
canvas_cull_mask = 0 will show my Layer 1.
canvas_cull_mask = 1 will show my Layer 2.
canvas_cull_mask = 3 will show both.
So still not using the “bit” of the layers, but it masks my layer number.
Also didn’t help that I had an await method not waiting, but that’s programmer error and unrelated to the above