Search Unity

CinemachineTrack : TrackAsset changes clip.displayName which is often used as a key to get clip

Discussion in 'Cinemachine' started by c0ffeeartc, Oct 9, 2019.

  1. c0ffeeartc

    c0ffeeartc

    Joined:
    Jul 23, 2015
    Posts:
    42
    Hello,

    CinemachineTrack : TrackAsset changes clip.displayName which is often used as a key to get clip by code from track. I switched to using indexes, but having keys is more robust in my case.

    Can this behaviour be revised? For example adding bool option on track to not change displayName. Or Timeline team could add key property alongside displayName to avoid usage collision.

    Thanks

    Code (CSharp):
    1.     [TrackColor(0.53f, 0.0f, 0.08f)]
    2.     public class CinemachineTrack : TrackAsset
    3.     {
    4.         public override Playable CreateTrackMixer(
    5.             PlayableGraph graph, GameObject go, int inputCount)
    6.         {
    7.             // Hack to set the display name of the clip to match the vcam
    8.             foreach (var c in GetClips())
    9.             {
    10.                 CinemachineShot shot = (CinemachineShot)c.asset;
    11.                 CinemachineVirtualCameraBase vcam = shot.VirtualCamera.Resolve(graph.GetResolver());
    12.                 if (vcam != null)
    13.                     c.displayName = vcam.Name;
    14.             }
    15.  
    16.             var mixer = ScriptPlayable<CinemachineMixer>.Create(graph);
    17.             mixer.SetInputCount(inputCount);
    18.             return mixer;
    19.         }
    20.     }
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,719
    Yes, we are aware of that behaviour, and agree that it's not optimal. We will look into revising that. Thanks for bringing this up.
     
  3. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,719
    FYI for the next CM release we have added an optional "Display Name" field to the CM shot. If non-empty, this name will be used in the timeline, else the vcam name will be used.

    Thanks for your input!