Exemple #1
0
        public static IMarker CloneMarkerToParent(IMarker marker, TrackAsset parent)
        {
            var markerObject = marker as ScriptableObject;

            if (markerObject == null)
            {
                return(null);
            }

            var newMarkerObject = Object.Instantiate(markerObject);

            AddMarkerToParent(newMarkerObject, parent);

            newMarkerObject.name = markerObject.name;
            try
            {
                CustomTimelineEditorCache.GetMarkerEditor((IMarker)newMarkerObject).OnCreate((IMarker)newMarkerObject, marker);
            }
            catch (Exception e)
            {
                Debug.LogException(e);
            }


            return((IMarker)newMarkerObject);
        }
Exemple #2
0
        public static IMarker CreateMarkerOnTrack(Type markerType, Object assignableObject, TrackAsset parentTrack, double candidateTime)
        {
            WindowState state = null;

            if (TimelineWindow.instance != null)
            {
                state = TimelineWindow.instance.state;
            }

            var newMarker = parentTrack.CreateMarker(markerType, candidateTime); //Throws if marker is not an object

            if (assignableObject != null)
            {
                var director = state != null ? state.editSequence.director : null;
                foreach (var field in ObjectReferenceField.FindObjectReferences(markerType))
                {
                    if (field.IsAssignable(assignableObject))
                    {
                        field.Assign(newMarker as ScriptableObject, assignableObject, director);
                        break;
                    }
                }
            }

            try
            {
                CustomTimelineEditorCache.GetMarkerEditor(newMarker).OnCreate(newMarker, null);
            }
            catch (Exception e)
            {
                Debug.LogException(e);
            }

            return(newMarker);
        }
Exemple #3
0
        public TimelineMarkerGUI(IMarker theMarker, IRowGUI parent, IZOrderProvider provider) : base(parent)
        {
            marker       = theMarker;
            m_Selectable = marker.GetType().IsSubclassOf(typeof(UnityObject));

            m_MarkerHash = 0;
            var o = marker as object;

            if (!o.Equals(null))
            {
                m_MarkerHash = o.GetHashCode();
            }

            zOrderProvider = provider;
            zOrder         = zOrderProvider.Next();
            ItemToItemGui.Add(marker, this);
            m_Editor = CustomTimelineEditorCache.GetMarkerEditor(theMarker);
        }
        public static IMarker CreateMarkerAtTime(TrackAsset parent, Type markerType, double time)
        {
            var marker = parent.CreateMarker(markerType, time);

            var obj = marker as ScriptableObject;

            if (obj != null)
            {
                obj.name = TypeUtility.GetDisplayName(markerType);
            }

            SelectionManager.Add(marker);

            try
            {
                CustomTimelineEditorCache.GetMarkerEditor(marker).OnCreate(marker, null);
            }
            catch (Exception e)
            {
                Debug.LogException(e);
            }

            return(marker);
        }