Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Cross-scene workflow?

Discussion in 'Timeline' started by oxysofts, Feb 21, 2020.

  1. oxysofts

    oxysofts

    Joined:
    Dec 17, 2015
    Posts:
    124
    It seems that Timelines can support references between multiple scenes just fine at runtime if you manually inject the references/bindings. However if you bind objects or components in other scenes, they will be lost when the timeline is re-opened for editing at a later time.

    Specific use-case: we use Cinemachine in our project. We have a global scene in the game which is active at all time, and contains the CinemachineBrain. We would like to use timelines for making cutscenes in our game, however cinemachine tracks in timeline require a binding to the brain which is in a global scene. As said before, we can inject the CinemachineTrack at runtime and it works just fine, however the workflow is quite a pain because we have to re-assign the binding each time we want to work on this cutscene.

    What is the recommended approach here? Do we absolutely need to create a new Camera and CinemachineBrain for every scene that will have cutscenes in it?
     
  2. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    There are a few different approaches, depending on your use case. In your case, it seems that a reasonable approach would be to simply bind the existing brain/cameras to the timeline when the playable director loads, possibly using a naming scheme on the tracks and clips to direct the binding.
     
    ROBYER1 likes this.
  3. oxysofts

    oxysofts

    Joined:
    Dec 17, 2015
    Posts:
    124
    Yes, but as I said it's not ideal when working on the timeline in edit mode because we then have to re-assign the brain manually each time. Is there a solution to this?
     
  4. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    bastianLstrube and ROBYER1 like this.
  5. olejuer

    olejuer

    Joined:
    Dec 1, 2014
    Posts:
    210
    @oxysofts have you considered an editor utility that does the same thing as your code that assigns the binding at runtime? As long as you have your cinemachine scene loaded, the binding could be established at the press of a button or maybe even fully automatically in the editor.

    It would be nice to have access to the track assets through the editor, though. Currently, they can only be discovered through code and custom utility has to be written. I think assigning bindings to tracks at runtime is a pretty powerful mechanic. This could also be an instance of a prefab that is created at runtime. It would be much simpler to handle with easier access to the track assets.
     
    bastianLstrube likes this.
  6. LaneFox

    LaneFox

    Joined:
    Jun 29, 2011
    Posts:
    7,462
    For anyone wondering, here's an example of how this can work.
    Code (csharp):
    1.         public PlayableDirector Director;
    2.  
    3.         private void OnEnable()
    4.         {
    5.             CinemachineBrain cam = Camera.main.GetComponent<CinemachineBrain>();
    6.  
    7.             foreach (PlayableBinding output in Director.playableAsset.outputs)
    8.             {
    9.                 if (output.outputTargetType != typeof(CinemachineBrain)) continue;
    10.                 Director.SetGenericBinding(output.sourceObject, cam);
    11.                 break;
    12.             }
    13.         }
    Assuming this is the intended approach, it is very obtuse.
     
    tconkling and mandisaw like this.