Search Unity

How to change scene through Timeline

Discussion in 'Timeline' started by TheArazm, Mar 21, 2018.

  1. TheArazm

    TheArazm

    Joined:
    Sep 17, 2014
    Posts:
    4
    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 ;)
     
  2. gekidoslayer

    gekidoslayer

    Unity Technologies

    Joined:
    Sep 27, 2016
    Posts:
    134
    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:

    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEngine.SceneManagement;
    3.  
    4. public class LoadOnActivation : MonoBehaviour
    5. {
    6.     void OnEnable()
    7.     {
    8.         // Only specifying the sceneName or sceneBuildIndex will load the Scene with the Single mode
    9.         SceneManager.LoadScene("OtherSceneName", LoadSceneMode.Additive);
    10.     }
    11. }
    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.
     
    Psynful16, akrivos, ZeroFlame and 7 others like this.
  3. TheArazm

    TheArazm

    Joined:
    Sep 17, 2014
    Posts:
    4
    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?
     
  4. TheArazm

    TheArazm

    Joined:
    Sep 17, 2014
    Posts:
    4
    Took a pic here if that explains it better ;)
     

    Attached Files:

  5. TheArazm

    TheArazm

    Joined:
    Sep 17, 2014
    Posts:
    4
    Found the issue.

    Had to use "Single" rather than "Additive" :)

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

    Have a great day! ;)
     
    Abhijeet1872 likes this.
  6. gekidoslayer

    gekidoslayer

    Unity Technologies

    Joined:
    Sep 27, 2016
    Posts:
    134
    No problem! Glad you got things sorted! This technique is very useful for linking Timeline with standard GameObject / MonoBehaviour scripts!
     
  7. just_bru

    just_bru

    Joined:
    Oct 19, 2018
    Posts:
    1
    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?
     
  8. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    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.
     
    Abhijeet1872 likes this.
  9. jretchford

    jretchford

    Joined:
    Dec 28, 2019
    Posts:
    3
    Was having the same issue and was wondering why I couldn't resolve it. Thank you so much for the simple fix!
     
  10. scarscarin

    scarscarin

    Joined:
    Apr 5, 2019
    Posts:
    23
    THANKS! Very useful, also used the LoadSceneMode.Single instead of Additive
     
  11. akent99

    akent99

    Joined:
    Jan 14, 2018
    Posts:
    588
    Just noting playing with the new Sequences beta I see "Scene Activation Track" as an option. (I assume this is new...)
     
  12. megarobusta

    megarobusta

    Joined:
    Jan 10, 2017
    Posts:
    1
    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.
     
  13. durazak

    durazak

    Joined:
    Jan 7, 2023
    Posts:
    1
    I cannot believe how much this thread has saved me! Thank you, everybody :)
     
  14. RookieGamer022

    RookieGamer022

    Joined:
    May 21, 2020
    Posts:
    1
    This thread helped me so much, thank you!!!
     
  15. jeancallisti

    jeancallisti

    Joined:
    Oct 27, 2017
    Posts:
    9
    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
    upload_2024-3-7_15-1-28.png
     
  16. MaximilianPs

    MaximilianPs

    Joined:
    Nov 7, 2011
    Posts:
    322
    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 :-\