When i change a property of a NoiseTexture2D (during runtime), it takes a while until the texture is updated in the viewport. Up to half a second in my case. Do i have any possibility to wait for this update in code before continuing?
There are SubViewports in the middle if this is an important info. (ViewportTexture)
I know i could just wait a second, but that’s wonky.
So, first: Thanks. Waiting for the Resource.changed signal helped. But it was a little more complicated in my case, as i have to wait for several of those threaded textures to be updated, without a lot of awaits blocking each other unnecessarily. Therefore i had to get creative. If there is any built in functionality i could replace this with, please tell me. Otherwise this might help others:
signal _await_queue_empty(group: StringName);
var _await_queue_id: int;
var _await_queue: Dictionary;
func wait_for_await_queue(
group: StringName = "main"
) -> void:
if self._await_queue[group].size() > 0:
while true:
var g = await self._await_queue_empty;
if g == group: return;
func add_to_await_queue(
object: Object,
_signal: StringName,
group: StringName = "main"
) -> void:
self._await_queue_id += 1;
var method := func(key: int, group: StringName):
var msg: Dictionary = self._await_queue[group][key];
self._await_queue[group].erase(key);
msg.object.disconnect(msg.signal, msg.method);
if self._await_queue[group].size() == 0:
self._await_queue_empty.emit(group);
if !self._await_queue.has(group):
self._await_queue[group] = {};
self._await_queue[group][self._await_queue_id] = {
"group": group, "method": method, "object": object, "signal": _signal
};
object.connect(_signal, method.bind(self._await_queue_id, group));