예제 #1
0
        public Track DuplicateTrack(Track srcTrack, bool includeKeys)
        {
            var dupTrack = SerializeData.CreateTrack(srcTrack.serializeType);

            srcTrack.CopyTo(dupTrack);

            dupTrack.maintainTrack(mDataTarget);

            Object tgtObj = dupTrack.GetTarget(mDataTarget);

            //if there's no target, then we can't add the keys for events and properties
            if (includeKeys && !(tgtObj == null && (dupTrack is PropertyTrack || dupTrack is EventTrack)))
            {
                foreach (var key in srcTrack.keys)
                {
                    var dupKey = SerializeData.CreateKey(key.serializeType);
                    if (dupKey != null)
                    {
                        key.CopyTo(dupKey);
                        dupKey.maintainKey(mDataTarget, tgtObj);
                        dupTrack.keys.Add(dupKey);
                    }
                }

                dupTrack.updateCache(mDataTarget);
            }

            return(dupTrack);
        }
예제 #2
0
        /// <summary>
        /// This will only duplicate the tracks and groups, includeKeys=true to also duplicate keys
        /// </summary>
        /// <param name="take"></param>
        public void DuplicateTake(Take dupTake, bool includeKeys)
        {
            Take a = new Take();

            a.name = dupTake.name;
            MakeTakeNameUnique(a);
            a.numLoop         = dupTake.numLoop;
            a.loopMode        = dupTake.loopMode;
            a.frameRate       = dupTake.frameRate;
            a.endFramePadding = dupTake.endFramePadding;
            //a.lsTracks = new List<Track>();
            //a.dictTracks = new Dictionary<int,Track>();

            if (dupTake.rootGroup != null)
            {
                a.rootGroup = dupTake.rootGroup.duplicate();
            }
            else
            {
                a.initGroups();
            }

            a.groupCounter = dupTake.groupCounter;

            if (dupTake.groupValues != null)
            {
                a.groupValues = new List <Group>();
                foreach (var grp in dupTake.groupValues)
                {
                    a.groupValues.Add(grp.duplicate());
                }
            }

            a.trackCounter = dupTake.trackCounter;

            a.trackValues = new List <Track>();
            foreach (var track in dupTake.trackValues)
            {
                var dupTrack = SerializeData.CreateTrack(track.serializeType);
                track.CopyTo(dupTrack);
                a.trackValues.Add(dupTrack);

                dupTrack.maintainTrack(mDataTarget);

                Object tgtObj = dupTrack.GetTarget(mDataTarget);

                //if there's no target, then we can't add the keys for events and properties
                if (includeKeys && !(tgtObj == null && (dupTrack is PropertyTrack || dupTrack is EventTrack)))
                {
                    foreach (var key in track.keys)
                    {
                        var dupKey = SerializeData.CreateKey(key.serializeType);
                        if (dupKey != null)
                        {
                            key.CopyTo(dupKey);
                            dupKey.maintainKey(mDataTarget, tgtObj);
                            dupTrack.keys.Add(dupKey);
                        }
                    }

                    dupTrack.updateCache(mDataTarget);
                }
            }

            takes.Add(a);
        }