Jump to content

How to determine when scene changes are complete


Recommended Posts

I'm trying to do a screenshot on a scene change. What I want to happen is to allow the scene to change, and then when the new scene is displayed, to do a snapshot of that.

I can detect scene changes using the following code:


private void RegisterEvents ()
{
Log.Info ("registering events");
GameEvents.onGameSceneLoadRequested.Add (this.CallbackGameSceneLoadRequested);
GameEvents.onLevelWasLoaded.Add (this.CallbackLevelWasLoaded);
}

// Set flags when scene change requested
private void CallbackGameSceneLoadRequested (GameScenes scene)
{
Log.Info ("CallbackGameSceneLoadRequested");
this.gui.SetVisible (scene == GameScenes.MAINMENU);
if (AS.configuration.screenshotOnSceneChange) {
this.newScene = true;
this.sceneReady = false;
}
}

// Set the sceneReady flag so a snapshot can be taken
private void CallbackLevelWasLoaded(GameScenes scene)
{
this.sceneReady = true;
}

public void Update()
{
// All excess code stripped for clarity
if (this.newScene && this.sceneReady) {
newScene = false;

do {
cnt++;
pngName = FileOperations.ScreenshotFolder () + configuration.filename + cnt.ToString () + ".png";
} while (FileOperations.ScreenshotFolder ().Contains (pngName));

Log.Info ("AutomatedScreenshots.Update: Screenshotfolder:" + pngName);
Application.CaptureScreenshot (pngName);
}

Unfortunately, this isn't doing what I want. It appears that the scene has changed, but it hasn't yet been displayed. I suspect it will have something to do with refresh, but would appreciate a pointer here.

Thanks

LGG

Edit: I added the update function for clarity

I also tried using the LateUpdate function, but no change

Edited by linuxgurugamer
Added Update functiion for clarity
Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...