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