0 votes

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?

in Engine by (124 points)

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

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

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.

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.

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

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?

1 Answer

0 votes

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.

by (3,390 points)

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

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

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.

Categories