Problem with black bars flashing when they have a texture set on them

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By psear

I have a main scene, and all other scenes in the game are instanced under it sequentially. It has multiple theming options, and I need the black bars to be consistent with the theme that is selected. It only needs to be a flat colour, but I couldn’t find a way to simply change their colour, so I used this:

VisualServer.black_bars_set_images(texRID, texRID, texRID, texRID)

This gets the RID from a 2x2 pixel png with the colour it needs. The problem is, whenever there is a change of scene, the black bars flash white, and I’m not sure why. If I disable this line, the black bars are there, and do not flash, and generally just behave as black bars would normally behave. How can I get rid of this white flashing? And is there a better way to simply change their colour, rather than using this workaround?

Where are you executing that instruction? I assume on an autoload script?

p7f | 2020-06-25 17:37

No, the function is executed on the main thread. Is that the wrong place to have it?

psear | 2020-06-25 18:00

What do you mean with the main thread? Which script has that instruction?
I’ve just tested this way and worked correctly. I created a script, i loaded the texture and called the black_bars_set_images function, and then set that script as an autoload in the project settings. If you have that function in a script attached to a scene, i think when you change the scene, possibly the resource is fred and then loaded again, and causes that glitch. But if you set it as an autoload (or singleton), it will remain loaded all time.

p7f | 2020-06-25 18:15

That might be it. It’s under the root node, in a function which is called by _ready(). I’ll try using an autoload script.

psear | 2020-06-25 18:19

Ok, i’ll add it as an answer, because it working for me. Tell me if it works!

p7f | 2020-06-25 18:21

I gave it a shot, I had a feeling it might not work because the node which calls this is never cleared, it’s all the nodes instanced under it which chain together. But is this really the way to change the colour of black bars? Is there a more “conventional” way?

psear | 2020-06-25 19:39

:bust_in_silhouette: Reply From: p7f

As i suggested in the comments above, try calling the VisualServer.black_bars_set_images(texRID, texRID, texRID, texRID) instruction in an autoload script. If you call it in the root of your scenes, the resource is going to be fred when you change the scene. I tried it on my game and it works.

Thanks for the reply. I’ve setup an autoload script and had the black bars set from there, but the issue persists. Any ideas?

psear | 2020-06-25 19:35

Not really, it works on my notebook. Could you share me the project so i test it here?

p7f | 2020-06-25 19:39