Beispiel #1
0
        public override DragAndDropVisualMode DoDrag(TreeViewItem parentItem, TreeViewItem targetItem, bool perform, TreeViewDragging.DropPosition dropPos)
        {
            this.m_Window.isDragging = false;
            DragAndDropVisualMode dragAndDropVisualMode = 0;

            TimelineDragging.TimelineDragData timelineDragData = DragAndDrop.GetGenericData("TimelineDragging") as TimelineDragging.TimelineDragData;
            if (timelineDragData != null)
            {
                dragAndDropVisualMode = this.HandleTrackDrop(parentItem, targetItem, perform, dropPos);
            }
            else if (DragAndDrop.get_objectReferences().Any <Object>() || DragAndDrop.get_paths().Any <string>())
            {
                dragAndDropVisualMode = this.HandleGameObjectDrop(parentItem, targetItem, perform, dropPos);
                if (dragAndDropVisualMode == null)
                {
                    dragAndDropVisualMode = this.HandleAudioSourceDrop(parentItem, targetItem, perform, dropPos);
                }
                if (dragAndDropVisualMode == null)
                {
                    dragAndDropVisualMode = this.HandleObjectDrop(parentItem, targetItem, perform, dropPos);
                }
            }
            this.m_Window.isDragging = false;
            if (dragAndDropVisualMode == 1 && targetItem != null)
            {
                TimelineGroupGUI timelineGroupGUI = targetItem as TimelineGroupGUI;
                if (timelineGroupGUI != null)
                {
                    timelineGroupGUI.isDropTarget = true;
                }
            }
            return(dragAndDropVisualMode);
        }
Beispiel #2
0
        public DragAndDropVisualMode HandleTrackDrop(TreeViewItem parentItem, TreeViewItem targetItem, bool perform, TreeViewDragging.DropPosition dropPos)
        {
            ((TimelineTreeView)this.m_Window.treeView.gui).showInsertionMarker = false;
            TimelineDragging.TimelineDragData timelineDragData = (TimelineDragging.TimelineDragData)DragAndDrop.GetGenericData("TimelineDragging");
            DragAndDropVisualMode             result;

            if (!TimelineDragging.ValidDrag(targetItem, timelineDragData.draggedItems))
            {
                result = 0;
            }
            else
            {
                TimelineGroupGUI timelineGroupGUI = targetItem as TimelineGroupGUI;
                if (timelineGroupGUI != null && timelineGroupGUI.track != null)
                {
                    ((TimelineTreeView)this.m_Window.treeView.gui).showInsertionMarker = true;
                }
                if (dropPos == null)
                {
                    TimelineGroupGUI timelineGroupGUI2 = targetItem as TimelineGroupGUI;
                    if (timelineGroupGUI2 != null)
                    {
                        timelineGroupGUI2.isDropTarget = true;
                    }
                }
                if (perform)
                {
                    List <TrackAsset> draggedActors = (from x in timelineDragData.draggedItems.OfType <TimelineGroupGUI>()
                                                       select x.track).ToList <TrackAsset>();
                    if (draggedActors.Count == 0)
                    {
                        result = 0;
                        return(result);
                    }
                    PlayableAsset    playableAsset     = this.m_Timeline;
                    TimelineGroupGUI timelineGroupGUI3 = parentItem as TimelineGroupGUI;
                    if (timelineGroupGUI3 != null && timelineGroupGUI3.track != null)
                    {
                        playableAsset = timelineGroupGUI3.track;
                    }
                    TrackAsset trackAsset = (timelineGroupGUI == null) ? null : timelineGroupGUI.track;
                    if (playableAsset == this.m_Timeline && dropPos == 1 && trackAsset == null)
                    {
                        trackAsset = this.m_Timeline.tracks.LastOrDefault((TrackAsset x) => !draggedActors.Contains(x));
                    }
                    if (TrackExtensions.ReparentTracks(draggedActors, playableAsset, trackAsset, dropPos == 2))
                    {
                        this.m_Window.state.Refresh(true);
                    }
                }
                result = 16;
            }
            return(result);
        }
Beispiel #3
0
        public TimelineGroupGUI(TreeViewController treeview, TimelineTreeViewGUI treeviewGUI, int id, int depth, TreeViewItem parent, string displayName, TrackAsset trackAsset, bool isRoot) : base(id, depth, parent, displayName, trackAsset, treeview, treeviewGUI)
        {
            this.m_Styles = DirectorStyles.Instance;
            this.m_IsRoot = isRoot;
            string assetPath  = AssetDatabase.GetAssetPath(trackAsset);
            string assetPath2 = AssetDatabase.GetAssetPath(treeviewGUI.TimelineWindow.timeline);

            if (assetPath != assetPath2)
            {
                this.m_IsReferencedTrack = true;
            }
            this.m_GroupDepth = TimelineGroupGUI.CalculateGroupDepth(parent);
        }
Beispiel #4
0
        public override void StartDrag(TreeViewItem draggedNode, List <int> draggedItemIDs)
        {
            DragAndDrop.PrepareStartDrag();
            List <TreeViewItem> draggedItems = SelectionManager.SelectedTrackGUI().Cast <TreeViewItem>().ToList <TreeViewItem>();

            DragAndDrop.SetGenericData("TimelineDragging", new TimelineDragging.TimelineDragData(draggedItems));
            DragAndDrop.set_objectReferences(new Object[0]);
            string           text             = draggedItemIDs.Count + ((draggedItemIDs.Count <= 1) ? "" : "s");
            TimelineGroupGUI timelineGroupGUI = draggedNode as TimelineGroupGUI;

            if (timelineGroupGUI != null)
            {
                text = timelineGroupGUI.get_displayName();
            }
            DragAndDrop.StartDrag(text);
        }
        public override void StartDrag(TreeViewItem draggedNode, List<int> draggedItemIDs)
        {
            DragAndDrop.PrepareStartDrag();
            var tvItems = SelectionManager.SelectedTrackGUI().Cast<TreeViewItem>().ToList();
            DragAndDrop.SetGenericData(k_GenericDragId, new TimelineDragData(tvItems));
            DragAndDrop.objectReferences = new UnityObject[] {};  // this IS required for dragging to work

            string title = draggedItemIDs.Count + (draggedItemIDs.Count > 1 ? "s" : ""); // title is only shown on OSX (at the cursor)

            TimelineGroupGUI groupGui = draggedNode as TimelineGroupGUI;
            if (groupGui != null)
            {
                title = groupGui.displayName;
            }
            DragAndDrop.StartDrag(title);
        }
Beispiel #6
0
        private static int CalculateGroupDepth(TreeViewItem parent)
        {
            int  num  = 0;
            bool flag = false;

            do
            {
                TimelineGroupGUI timelineGroupGUI = parent as TimelineGroupGUI;
                if (timelineGroupGUI == null || timelineGroupGUI.track == null)
                {
                    flag = true;
                }
                else
                {
                    if (timelineGroupGUI.track.mediaType == TimelineAsset.MediaType.Group)
                    {
                        num++;
                    }
                    parent = parent.get_parent();
                }
            }while (!flag);
            return(num);
        }
Beispiel #7
0
        protected float GetChildrenHeight(TreeViewItem item)
        {
            float num = 0f;
            TimelineTrackBaseGUI timelineTrackBaseGUI = item as TimelineTrackBaseGUI;
            bool flag = timelineTrackBaseGUI != null && timelineTrackBaseGUI.track.GetCollapsed();

            if (item.get_children() != null && !flag)
            {
                IList <TreeViewItem> rows = this.treeView.get_data().GetRows();
                for (int num2 = 0; num2 != item.get_children().Count; num2++)
                {
                    TreeViewItem treeViewItem = item.get_children()[num2];
                    if (this.treeView.get_data().IsRevealed(treeViewItem.get_id()))
                    {
                        int num3 = rows.IndexOf(treeViewItem);
                        if (num3 >= 0)
                        {
                            num += this.m_TreeViewGUI.GetRowRect(num3).get_height();
                            TimelineGroupGUI timelineGroupGUI = treeViewItem as TimelineGroupGUI;
                            if (timelineGroupGUI != null)
                            {
                                if (timelineGroupGUI.track != null)
                                {
                                    TrackAsset trackAsset = timelineGroupGUI.track.parent as TrackAsset;
                                    if (trackAsset != null)
                                    {
                                        num += 3f;
                                    }
                                }
                            }
                        }
                    }
                    num += this.GetChildrenHeight(treeViewItem);
                }
            }
            return(num);
        }
Beispiel #8
0
        public DragAndDropVisualMode HandleObjectDrop(TreeViewItem parentItem, TreeViewItem targetItem, bool perform, TreeViewDragging.DropPosition dropPos)
        {
            DragAndDropVisualMode result;

            if (!perform)
            {
                List <Object> list = new List <Object>();
                if (DragAndDrop.get_objectReferences().Any <Object>())
                {
                    list.AddRange(DragAndDrop.get_objectReferences());
                    using (List <Object> .Enumerator enumerator = list.GetEnumerator())
                    {
                        while (enumerator.MoveNext())
                        {
                            Object      o = enumerator.Current;
                            TrackType[] trackTypeHandle = TimelineHelpers.GetTrackTypeHandle(o.GetType());
                            if (!trackTypeHandle.Any <TrackType>() || trackTypeHandle.Any((TrackType t) => !TimelineDragging.ValidateObjectDrop(o)))
                            {
                                result = 0;
                                return(result);
                            }
                        }
                    }
                    result = 1;
                }
                else if (DragAndDrop.get_paths().Any <string>())
                {
                    TimelineGroupGUI timelineGroupGUI = targetItem as TimelineGroupGUI;
                    if (timelineGroupGUI == null)
                    {
                        result = 1;
                    }
                    else if (timelineGroupGUI.track == null)
                    {
                        result = 0;
                    }
                    else
                    {
                        TrackType tt    = TimelineHelpers.TrackTypeFromType(timelineGroupGUI.track.GetType());
                        string[]  paths = DragAndDrop.get_paths();
                        for (int i = 0; i < paths.Length; i++)
                        {
                            string text = paths[i];
                            list.AddRange(AssetDatabase.LoadAllAssetsAtPath(text));
                        }
                        bool flag = (from o in list
                                     where o != null
                                     select o).Any((Object o) => TimelineHelpers.IsTypeSupportedByTrack(tt, o.GetType()));
                        result = ((!flag) ? 0 : 1);
                    }
                }
                else
                {
                    result = 0;
                }
            }
            else
            {
                List <Object> list2 = new List <Object>();
                list2.AddRange(DragAndDrop.get_objectReferences());
                TrackAsset       trackAsset        = null;
                TimelineGroupGUI timelineGroupGUI2 = (TimelineGroupGUI)targetItem;
                if (targetItem != null && timelineGroupGUI2.track != null)
                {
                    trackAsset = timelineGroupGUI2.track;
                }
                Vector2 mousePosition = Event.get_current().get_mousePosition();
                foreach (Object current in list2)
                {
                    if (!(current == null))
                    {
                        if (current is TimelineAsset)
                        {
                            if (TimelineHelpers.IsCircularRef(this.m_Timeline, current as TimelineAsset))
                            {
                                Debug.LogError("Cannot add " + current.get_name() + " to the sequence because it would cause a circular reference");
                                continue;
                            }
                            TimelineAsset timelineAsset = current as TimelineAsset;
                            foreach (TrackAsset current2 in timelineAsset.tracks)
                            {
                                if (current2.mediaType == TimelineAsset.MediaType.Group)
                                {
                                    this.m_Timeline.AddTrackInternal(current2);
                                }
                            }
                            this.m_Window.state.Refresh();
                            EditorUtility.SetDirty(this.m_Timeline);
                        }
                        else if (current is TrackAsset)
                        {
                            this.m_Timeline.AddTrackInternal((TrackAsset)current);
                        }
                        else
                        {
                            TrackType   trackType        = null;
                            TrackAsset  trackAsset2      = null;
                            TrackType[] trackTypeHandle2 = TimelineHelpers.GetTrackTypeHandle(current.GetType());
                            if (trackAsset != null)
                            {
                                TrackType[] array = trackTypeHandle2;
                                for (int j = 0; j < array.Length; j++)
                                {
                                    TrackType trackType2 = array[j];
                                    if (trackAsset.GetType() == trackType2.trackType)
                                    {
                                        trackType = trackType2;
                                        break;
                                    }
                                }
                            }
                            if (trackType == null)
                            {
                                if (trackTypeHandle2.Length == 1)
                                {
                                    trackType = trackTypeHandle2[0];
                                }
                                else if (trackTypeHandle2.Length > 1)
                                {
                                    trackType = this.ResolveTypeAmbiguity(trackTypeHandle2);
                                }
                            }
                            if (trackType == null)
                            {
                                continue;
                            }
                            if (!TimelineDragging.ValidateObjectDrop(current))
                            {
                                continue;
                            }
                            if (trackAsset != null && trackAsset.GetType() == trackType.trackType)
                            {
                                trackAsset2 = trackAsset;
                            }
                            if (trackAsset2 == null)
                            {
                                trackAsset2 = this.m_Window.AddTrack(trackType.trackType, null, string.Empty);
                            }
                            if (trackAsset2 == null)
                            {
                                result = 0;
                                return(result);
                            }
                            Object @object = TimelineDragging.TransformObjectBeingDroppedAccordingToTrackRules(trackAsset2, current);
                            if (@object == null)
                            {
                                continue;
                            }
                            TimelineUndo.PushUndo(trackAsset2, "Create Clip");
                            AnimationTrack animationTrack = trackAsset2 as AnimationTrack;
                            if (animationTrack != null)
                            {
                                animationTrack.ConvertToClipMode();
                            }
                            TimelineClip timelineClip = TimelineHelpers.CreateClipOnTrack(@object, trackAsset2, this.m_Window.state, mousePosition);
                            if (timelineClip != null)
                            {
                                float num = this.m_Window.state.TimeToPixel(1.0) - this.m_Window.state.TimeToPixel(0.0);
                                mousePosition.x += (float)timelineClip.duration * num;
                                if (timelineClip.asset is ScriptableObject)
                                {
                                    string assetPath = AssetDatabase.GetAssetPath(timelineClip.asset);
                                    if (assetPath.Length == 0)
                                    {
                                        TimelineCreateUtilities.SaveAssetIntoObject(timelineClip.asset, trackAsset2);
                                    }
                                }
                                TimelineDragging.FrameClips(this.m_Window.state);
                                trackAsset2.SetCollapsed(false);
                            }
                        }
                        this.m_Window.state.Refresh();
                        EditorUtility.SetDirty(this.m_Timeline);
                    }
                }
                result = 1;
            }
            return(result);
        }