How to change scene through Timeline

Hello!

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!

Thanks for reading :wink:

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.

10 Likes

Hello!

Thank you so much for the reply!

I tried everything, and i did get a response, but not the one i was hoping for.

The scene never changes, but it just shows up in my hierarchy instead?

Am i missing something to make the next scene show?

Took a pic here if that explains it better :wink:

Found the issue.

Had to use “Single” rather than “Additive” :slight_smile:

Thank you so much for the great help! Awesome to have my very first question on the forum be answered with such speed! :smile:

Have a great day! :wink:

1 Like

No problem! Glad you got things sorted! This technique is very useful for linking Timeline with standard GameObject / MonoBehaviour scripts!

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.

1 Like

Was having the same issue and was wondering why I couldn’t resolve it. Thank you so much for the simple fix!

THANKS! Very useful, also used the LoadSceneMode.Single instead of Additive

Just noting playing with the new Sequences beta I see “Scene Activation Track” as an option. (I assume this is new…)

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.

I cannot believe how much this thread has saved me! Thank you, everybody :slight_smile:

This thread helped me so much, thank you!!!

To anyone wondering : to DEACTIVATE a game object (with the UI) :

  • Click on the object
  • Go to the Inspector panel
  • Click the tick box next to the name of the object

9686243--1381577--upload_2024-3-7_15-1-28.png

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 :-\