Exemple #1
0
        public static TimelineClip Clone(TimelineClip clip, PlayableDirector directorInstance)
        {
            EditorClip   editorClip = EditorItemFactory.GetEditorClip(clip);
            TimelineClip clip2      = Object.Instantiate <EditorClip>(editorClip).clip;

            SelectionManager.Remove(clip2);
            clip2.parentTrack = null;
            clip2.ClearAnimatedParameterCurves();
            if (clip.curves != null)
            {
                AnimatedParameterExtensions.CreateCurvesIfRequired(clip2, clip.parentTrack);
                EditorUtility.CopySerialized(clip.curves, clip2.curves);
            }
            ScriptableObject scriptableObject = clip2.asset as ScriptableObject;

            if (scriptableObject != null && clip2.asset is IPlayableAsset)
            {
                ScriptableObject scriptableObject2 = TimelineHelpers.CloneReferencedPlayableAsset(scriptableObject, directorInstance);
                TimelineHelpers.SaveCloneToOriginalAsset(scriptableObject, scriptableObject2);
                clip2.asset = scriptableObject2;
                AnimationPlayableAsset animationPlayableAsset = scriptableObject2 as AnimationPlayableAsset;
                if (clip2.recordable && animationPlayableAsset != null && animationPlayableAsset.clip != null)
                {
                    clip2.displayName = animationPlayableAsset.clip.get_name();
                }
            }
            return(clip2);
        }