SendCustomEventDelayedSeconds continues after leaving worlds
complete
Guribo
When creating a delayed custom event that continues to call itself with a new delay it will never stop when leaving e.g. the world.
I don't know if this is expected behaviour. I expected that upon destruction or disabling of the udon behaviour relevant delayed events are removed from the queue of delayed events.
Short example (U# 0.19.9/Network beta sdk v5):
void Start()
{
SendCustomEventDelayedSeconds("Loop", Random.Range(5f, 15f), EventTiming.LateUpdate);
}
public void Loop()
{
Debug.Log("Looping with random delay");
SendCustomEventDelayedSeconds("Loop", Random.Range(5f, 15f), EventTiming.LateUpdate);
}
A solution could be to check inside
SendCustomEventDelayedSeconds
whether the udonbehaviour is active both upon enqueuing and right before execution: # could be replaced with native C# '!this.isActiveAndEnabled'
if (!(Utilities.IsValid(this)
&& enabled
&& Utilities.IsValid(gameObject)
&& gameObject.activeInHierarchy))
{
// not active/updating
return;
}
After leaving the world:
Photo Viewer
View photos in a modal
Log In
Phasedragon
marked this post as
complete
Phasedragon
Is this unique to Udon Networking Update?
Guribo
Phasedragon: I just tested it on live, open beta and network beta with an udon graph behaviour. All versions show the same behaviour: when I leave the world it continues to log.
Photo Viewer
View photos in a modal
Phasedragon
Guribo: Thank you. I'm going to move it out of the UNU section then.