public static void BindWithEditorValidation(PlayableDirector director, TrackAsset bindTo, Object objectToBind)
        {
            TrackEditor trackEditor     = CustomTimelineEditorCache.GetTrackEditor(bindTo);
            Object      validatedObject = trackEditor.GetBindingFrom_Safe(objectToBind, bindTo);

            Bind(director, bindTo, validatedObject);
        }
 public static void OnTrackChanged_Safe(this TrackEditor editor, TrackAsset track)
 {
     try
     {
         editor.OnTrackChanged(track);
     }
     catch (Exception e)
     {
         Debug.LogException(e);
     }
 }
 public static void OnCreate_Safe(this TrackEditor editor, TrackAsset track, TrackAsset copiedFrom)
 {
     try
     {
         editor.OnCreate(track, copiedFrom);
     }
     catch (Exception e)
     {
         Debug.LogException(e);
     }
 }
 public static bool IsBindingAssignableFrom_Safe(this TrackEditor editor, UnityEngine.Object candidate, TrackAsset track)
 {
     try
     {
         return(editor.IsBindingAssignableFrom(candidate, track));
     }
     catch (Exception e)
     {
         Debug.LogException(e);
         return(false);
     }
 }
 public static UnityEngine.Object GetBindingFrom_Safe(this TrackEditor editor, UnityEngine.Object candidate, TrackAsset track)
 {
     try
     {
         return(editor.GetBindingFrom(candidate, track));
     }
     catch (Exception e)
     {
         Debug.LogException(e);
         return(candidate);
     }
 }
 public static TrackDrawOptions GetTrackOptions_Safe(this TrackEditor editor, TrackAsset track, UnityEngine.Object binding)
 {
     try
     {
         return(editor.GetTrackOptions(track, binding));
     }
     catch (Exception e)
     {
         Debug.LogException(e);
         return(CustomTimelineEditorCache.GetDefaultTrackEditor().GetTrackOptions(track, binding));
     }
 }
Exemple #7
0
        public TimelineTrackGUI(TreeViewController tv, TimelineTreeViewGUI w, int id, int depth, TreeViewItem parent, string displayName, TrackAsset sequenceActor)
            : base(tv, w, id, depth, parent, displayName, sequenceActor, false)
        {
            AnimationTrack animationTrack = sequenceActor as AnimationTrack;

            if (animationTrack != null)
            {
                m_InfiniteTrackDrawer = new InfiniteTrackDrawer(new AnimationTrackKeyDataSource(animationTrack));
            }
            else if (sequenceActor.HasAnyAnimatableParameters() && !sequenceActor.clips.Any())
            {
                m_InfiniteTrackDrawer = new InfiniteTrackDrawer(new TrackPropertyCurvesDataSource(sequenceActor));
            }

            UpdateInfiniteClipEditor(w.TimelineWindow);

            var bindings = track.outputs.ToArray();

            m_TrackDrawData.m_HasBinding = bindings.Length > 0;
            if (m_TrackDrawData.m_HasBinding)
            {
                m_TrackDrawData.m_Binding = bindings[0];
            }
            m_TrackDrawData.m_IsSubTrack      = IsSubTrack();
            m_TrackDrawData.m_AllowsRecording = DoesTrackAllowsRecording(sequenceActor);
            m_DefaultTrackIcon = TrackResourceCache.GetTrackIcon(track);


            m_TrackEditor = CustomTimelineEditorCache.GetTrackEditor(sequenceActor);

            try
            {
                m_TrackDrawOptions = m_TrackEditor.GetTrackOptions(track, null);
            }
            catch (Exception e)
            {
                Debug.LogException(e);
                m_TrackDrawOptions = CustomTimelineEditorCache.GetDefaultTrackEditor().GetTrackOptions(track, null);
            }

            m_TrackDrawOptions.errorText = null; // explicitly setting to null for an uninitialized state

            RebuildGUICacheIfNecessary();
        }
        public static void BindWithInteractiveEditorValidation(PlayableDirector director, TrackAsset bindTo, Object objectToBind)
        {
            TrackEditor trackEditor = CustomTimelineEditorCache.GetTrackEditor(bindTo);

            if (trackEditor.SupportsBindingAssign())
            {
                BindWithEditorValidation(director, bindTo, objectToBind);
            }
            else
            {
                Type          bindingType = TypeUtility.GetTrackBindingAttribute(bindTo.GetType())?.type;
                BindingAction action      = GetBindingAction(bindingType, objectToBind);
                if (action == BindingAction.BindToMissingComponent)
                {
                    InteractiveBindToMissingComponent(director, bindTo, objectToBind, bindingType);
                }
                else
                {
                    var validatedObject = GetBinding(action, objectToBind, bindingType);
                    Bind(director, bindTo, validatedObject);
                }
            }
        }
 public static bool SupportsBindingAssign(this TrackEditor editor)
 {
     return(TypeUtility.HasOverrideMethod(editor.GetType(), nameof(TrackEditor.GetBindingFrom)));
 }