Example #1
0
 void AMITarget.MaintainTargetCache(AMTrack track)
 {
     if ((this as AMITarget).isMeta && mCache.ContainsKey(track.targetPath))
     {
         UnityEngine.Object obj = track.GetTarget(this);
         if (obj)
         {
             string objPath = AMUtil.GetPath(transform, obj);
             if (objPath != track.targetPath)
             {
                 mCache.Remove(track.targetPath);
             }
         }
     }
 }
Example #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(AMTakeData dupTake, bool includeKeys, bool addCompUndo)
        {
            AMTakeData a = new AMTakeData();

            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<AMTrack>();
            //a.dictTracks = new Dictionary<int,AMTrack>();

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

            a.group_count = dupTake.group_count;

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

            a.track_count = dupTake.track_count;

            if (dupTake.trackValues != null)
            {
                a.trackValues = new List <AMTrack>();
                foreach (AMTrack track in dupTake.trackValues)
                {
                    GameObject holderGO = (this as AMITarget).holder.gameObject;
                    AMTrack    dupTrack = (addCompUndo ? UnityEditor.Undo.AddComponent(holderGO, track.GetType()) : holderGO.AddComponent(track.GetType())) as AMTrack;
                    dupTrack.enabled = false;
                    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 AMPropertyTrack || dupTrack is AMEventTrack)))
                    {
                        foreach (AMKey key in track.keys)
                        {
                            AMKey dupKey = (addCompUndo ? UnityEditor.Undo.AddComponent(holderGO, key.GetType()) : holderGO.AddComponent(key.GetType())) as AMKey;
                            if (dupKey)
                            {
                                key.CopyTo(dupKey);
                                dupKey.enabled = false;
                                dupKey.maintainKey(mDataTarget, tgtObj);
                                dupTrack.keys.Add(dupKey);
                            }
                        }

                        dupTrack.updateCache(mDataTarget);
                    }
                }
            }

            takes.Add(a);
        }