コード例 #1
0
        /// <summary>
        /// Assigns the track to the specified group track.
        /// </summary>
        /// <param name="asset">The track to assign.</param>
        /// <param name="group">The GroupTrack to assign the track to.</param>
        /// <remarks>
        /// Does not support assigning to a group in a different timeline.
        /// </remarks>
        public static void SetGroup(this TrackAsset asset, GroupTrack group)
        {
            const string undoString = "Reparent";

            if (asset == null || asset == group || asset.parent == group)
            {
                return;
            }

            if (group != null && asset.timelineAsset != group.timelineAsset)
            {
                throw new InvalidOperationException("Cannot assign to a group in a different timeline");
            }


            TimelineUndo.PushUndo(asset, undoString);

            var timeline       = asset.timelineAsset;
            var parentTrack    = asset.parent as TrackAsset;
            var parentTimeline = asset.parent as TimelineAsset;

            if (parentTrack != null || parentTimeline != null)
            {
                TimelineUndo.PushUndo(asset.parent, undoString);
                if (parentTimeline != null)
                {
                    parentTimeline.RemoveTrack(asset);
                }
                else
                {
                    parentTrack.RemoveSubTrack(asset);
                }
            }

            if (group == null)
            {
                TimelineUndo.PushUndo(timeline, undoString);
                asset.parent = asset.timelineAsset;
                timeline.AddTrackInternal(asset);
            }
            else
            {
                TimelineUndo.PushUndo(group, undoString);
                group.AddChild(asset);
            }
        }
コード例 #2
0
 public static void SetGroup(this TrackAsset asset, GroupTrack group)
 {
     if (!(asset == null) && !(asset == group) && !(asset.parent == group))
     {
         if (group != null && asset.timelineAsset != group.timelineAsset)
         {
             throw new InvalidOperationException("Cannot assign to a group in a different timeline");
         }
         TimelineUndo.PushUndo(asset, "Reparent");
         TimelineAsset timelineAsset  = asset.timelineAsset;
         TrackAsset    trackAsset     = asset.parent as TrackAsset;
         TimelineAsset timelineAsset2 = asset.parent as TimelineAsset;
         if (trackAsset != null || timelineAsset2 != null)
         {
             TimelineUndo.PushUndo(asset.parent, "Reparent");
             if (timelineAsset2 != null)
             {
                 timelineAsset2.RemoveTrack(asset);
             }
             else
             {
                 trackAsset.RemoveSubTrack(asset);
             }
         }
         if (group == null)
         {
             TimelineUndo.PushUndo(timelineAsset, "Reparent");
             asset.parent = asset.timelineAsset;
             timelineAsset.AddTrackInternal(asset);
         }
         else
         {
             TimelineUndo.PushUndo(group, "Reparent");
             group.AddChild(asset);
         }
     }
 }