Notifications
Clear all

[Closed] Need to wait at least one clock cycle after loading scene

Just thought I’d share something I just learned, in case someone else is having the same problem.

I have a floater that I want to update with scene data as soon as a scene is loaded. So I was using callbacks to detect when a scene was loaded, reset, or made new, and then running UI updating scripts as a result.

Specifically, I was querying Max’s scene state manager interface, but instead of giving me the values that it normally does, it would return undefined values when triggered by one of those callback events.

So the solution was to use a timer UI item in my floater, and set it to fire just one millisecond after the callbacks are triggered (of course, you could set the delay for as long as you wanted, but I wanted it to appear instantaneous). I’m assuming this gives the Max app an extra clock cycle to initialize all the proper things before querying them.

Anyone else run into this situation?

2 Replies

What notification method are you using? (filePostOpen, filePostOpenProcess…)

I’m using #filePostOpen, #systemPostNew, and #systemPostReset for my callbacks. In the callback I was trying to access sceneStateMgr.MapIndexToPart(), but it only returns an undefined. But if I force it to wait for a small period of time before accessing the property, it works just fine.