Cross-scene workflow?

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?

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.

1 Like

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?

There isn’t a built-in solution to this, although there may be some others floating around. Internally, we’ve looked at this Unity Blog, to help with timeline cross scene binding, but haven’t fully investigated yet.

2 Likes

@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.

1 Like

For anyone wondering, here’s an example of how this can work.

        public PlayableDirector Director;

        private void OnEnable()
        {
            CinemachineBrain cam = Camera.main.GetComponent<CinemachineBrain>();

            foreach (PlayableBinding output in Director.playableAsset.outputs)
            {
                if (output.outputTargetType != typeof(CinemachineBrain)) continue;
                Director.SetGenericBinding(output.sourceObject, cam);
                break;
            }
        }

Assuming this is the intended approach, it is very obtuse.

2 Likes