So, I’ve been using Cinema Suite (Cinema Director) for a while, and saw through the keynote a few days ago, that there is a new kid in town, the Timeline.
I tried it out with Cinemachine, and boy i love the camera handling, as well as the overlapping of camera’s, so that you get a smooth transition from cam to cam.
But as my scene started to take form, i soon realized that i couldn’t find a trigger, to call a new scene to be opened, upon ending the timeline.
IS this just not a feature of Timeline? Because i really like the overall feel of the tools, and would rather use this than Cinema Suite (It’s porely optimized in the 2018.1.11 beta).
I hope that someone has an answer, and can help me figure out how to do this! The only thing i need, is to change the scene at the end of my cutscene!
It’s pretty easy to use activation tracks to enable / run scripts at any point - I’m using this for triggers, events for purposes like this.
All you need is a simple monobehaviour on a gameobject that does whatever action you want to trigger in an OnEnable() method
Something as simple as this attached to an object that bind to an activation track will do the trick:
using UnityEngine;
using UnityEngine.SceneManagement;
public class LoadOnActivation : MonoBehaviour
{
void OnEnable()
{
// Only specifying the sceneName or sceneBuildIndex will load the Scene with the Single mode
SceneManager.LoadScene("OtherSceneName", LoadSceneMode.Additive);
}
}
Add the script to a gameobject, drag it onto Timeline and add an ‘activation track’ and it will load the new scene when the activation clip is triggered.
When i add this code to an empty game object and add it to an activation track, no matter where the animation clip is, is loads the new scene as soon as i press play in the editor. You guys have any ideas?
Make sure you are not in preview mode in Timeline, and disable the game object in the scene. It sounds like it is active by default. So it loads enabled, then timeline disables it.
Thanks @mikew_unity for this! Adding that the LoadSceneMode.Additive can be set to LoadSceneMode.Single to totally replace the scene with the new (loaded) scene.
WARNING
Don’t forget to disable your gameObject as normal state or Unity will stop to respond and the only way to exit from this state is to kill it :-\