Hi,
I've got Dialogue System Portals set up to transition between scenes. In the inspector I can set up a custom method to be called thanks to the OnUsePortal() event, which works just fine. Now, I'd like to call custom methods as soon as the new scene finishes loading. I've tried the Standard Scene Transition manager's EnterSceneTransition.OnTransitionEnd() in the inspector but nothings happens. Am I looking at the wrong place?
Also, I've got a bit of an annoying bug. As soon as the Scene Fade into is over (I'm using the standard fade to/from black), the camera visibly moves to the player's spawn position instead of already being there. This happens, when the spawn coordinates are not 0/0/0. I'd like the player (the person playing the game) not to see this zooming around the level.
Thank you for your time.
Trigger a method upon finishing entering a scene by Portal
Re: Trigger a method upon finishing entering a scene by Portal
Hi,
The OnTransitionEnd UnityEvent should work when the transition is done. Make sure your scene has only one Save System component. The Save System component only allows one instance. At runtime, it will automatically destroy any other GameObjects that have a Save System component. Note that the Save System survives scene changes, so you shouldn't assign any scene-specific GameObjects to its UnityEvents. The same issue is discussed here: How To: Manage Player Controls and Scene Changesphoot wrote: ↑Tue Oct 10, 2023 11:53 amI've got Dialogue System Portals set up to transition between scenes. In the inspector I can set up a custom method to be called thanks to the OnUsePortal() event, which works just fine. Now, I'd like to call custom methods as soon as the new scene finishes loading. I've tried the Standard Scene Transition manager's EnterSceneTransition.OnTransitionEnd() in the inspector but nothing happens. Am I looking at the wrong place?
This will depend on how your camera works. The simplest solution is often to extend the fade from black so it hides the camera movement. Alternatively, you can tell the camera to jump to its destination position. If you're using Cinemachine, you can do this by disabling and re-enabling the vcam, depending on which version of Cinemachine you're using. Its behavior changes across versions. If you're using a camera controller included in any controllers assets that the Dialogue System has integration with, the integration should jump the camera to the correct position. Otherwise you may need to write a little script to do it.phoot wrote: ↑Tue Oct 10, 2023 11:53 amAlso, I've got a bit of an annoying bug. As soon as the Scene Fade into is over (I'm using the standard fade to/from black), the camera visibly moves to the player's spawn position instead of already being there. This happens, when the spawn coordinates are not 0/0/0. I'd like the player (the person playing the game) not to see this zooming around the level.
Re: Trigger a method upon finishing entering a scene by Portal
Thank you for your quick replies, this time around they didn't get eaten by the bad data void monster
My problem came from certain objects that should survive scene transition didn't, and vice versa. Your hints helped me sort it out.
I've tried the jump to position strategy based on a custom script but I don't quite like it. I will be trying your suggestions once I've sorted out my current tasks.
I have a follow up question. How can I wait for to finish and, upon that properly finishing, excecute other pieces of code? I should clarify that I would like to wait until the scene finished loading so I can load persistent data into my player object. I can't use the transition manager transitions since this is only supposed to happen from menu buttons. Currently I'm getting null reference exceptions which I don't understand why they keep happening, given that the above method uses a coroutine. Shouldn't it finish its job, then execute the next line of code?
Sorry if I'm being stupid.
My problem came from certain objects that should survive scene transition didn't, and vice versa. Your hints helped me sort it out.
I've tried the jump to position strategy based on a custom script but I don't quite like it. I will be trying your suggestions once I've sorted out my current tasks.
I have a follow up question. How can I wait for
Code: Select all
PixelCrushers.SaveSystem.LoadScene("Level");
Sorry if I'm being stupid.
Re: Trigger a method upon finishing entering a scene by Portal
Hi,
Hook into the C# event SaveSystem.sceneLoaded or SaveSystem.saveDataApplied.
SaveSystem.sceneLoaded is invoked after the scene has been loaded, but before the save data has been applied.
SaveSystem.saveDataApplied is invoked after the save data has been applied.
Example:
Hook into the C# event SaveSystem.sceneLoaded or SaveSystem.saveDataApplied.
SaveSystem.sceneLoaded is invoked after the scene has been loaded, but before the save data has been applied.
SaveSystem.saveDataApplied is invoked after the save data has been applied.
Example:
Code: Select all
SaveSystem.saveDataAppled += OnSaveDataApplied;
SaveSystem.LoadScene("scene name");
void OnSaveDataApplied()
{
SaveSystem.saveDataAppled -= OnSaveDataApplied;
// (Your code here)
}
Re: Trigger a method upon finishing entering a scene by Portal
That's exactly what I needed. Thank you again Tony!