Search Unity

  1. We are migrating the Unity Forums to Unity Discussions by the end of July. Read our announcement for more information and let us know if you have any questions.
    Dismiss Notice
  2. Dismiss Notice

Question How to detect a CTRL+D duplicated clip?

Discussion in 'Timeline' started by unity_QEGfEDvVxu5QUg, Jan 22, 2024.

  1. unity_QEGfEDvVxu5QUg

    unity_QEGfEDvVxu5QUg

    Joined:
    Jan 11, 2023
    Posts:
    9
    I'm creating a custom track that uses a project-managed ScriptableObject (PlayableAsset) as the clip. I can drag the SO into the timeline from the project tab and it works as expected.

    However, if a user duplicates one of these clips via CTRL+D, the result is a deep copy of the asset embedded in the timeline; I would like it to remain a reference to the project file.

    I imagine I could figure a workaround by myself if only I had some callback for when a clip is duplicated, but I can't find one. OnCreateClip and OnValidate aren't called on the track class like they are for regular new tracks (weird?) and I couldn't get OnAfterTrackDeserialize to execute reliably either. OnBeforeTrackSerialize fires but the duplicated track doesn't seem to be available yet.

    It sure seems like OnCreateClip and OnValidate should fire when a clip is duplicated...

    Thanks for reading this. Any advice appreciated greatly.

    PS. Unity 2022.3.17 & Timeline 1.7.6
     
  2. tsukimi

    tsukimi

    Joined:
    Dec 10, 2014
    Posts:
    84
    How About seperate your project-managed ScriptableObject into two ScriptableObects, one is as an clip asset (①), and the other is your original ScriptableObject logics/datas (②)?
    The ① clip asset could contain your ② ScriptableObject using [SerializedField], hence is almost the same.
     
  3. unity_QEGfEDvVxu5QUg

    unity_QEGfEDvVxu5QUg

    Joined:
    Jan 11, 2023
    Posts:
    9
    Interesting idea, thank you. I'll keep that in mind if can't find a more direct way. I'm still hopeful there's some callback or api I'm overlooking...