Ejemplo n.º 1
0
        public AMSequence(AMITarget itarget, int id, AMTakeData take)
        {
            mTarget = itarget;
            mId = id;
            mTake = take;

            if(mTake.loopBackToFrame > 0 && mTake.numLoop <= 0)
                mTake.numLoop = 1;
        }
Ejemplo n.º 2
0
        public void addGroup(AMTakeData take)
        {
            take.initGroups();
            AMGroup g = new AMGroup();
            g.init(take.getUniqueGroupID());
            take.groupValues.Add(g);
            take.rootGroup.elements.Add(g.group_id);

            // select new group when it has been created
            selectedGroup = g.group_id;
        }
Ejemplo n.º 3
0
	    public static MonoBehaviour[] GetKeysAndTracks(AMTakeData take) {
	        List<MonoBehaviour> behaviours = new List<MonoBehaviour>();

	        if(take.trackValues != null) {
	            foreach(AMTrack track in take.trackValues) {
	                if(track.keys != null) {
	                    foreach(AMKey key in track.keys)
	                        behaviours.Add(key);
	                }

	                behaviours.Add(track);
	            }
	        }

	        return behaviours.ToArray();
	    }
Ejemplo n.º 4
0
 public void shiftOutOfBoundsKeysOnTrack(AMTakeData take, AMITarget itarget, AMTrack _track)
 {
     int offset = _track.shiftOutOfBoundsKeys(itarget);
     if(contextSelection.Count <= 0) return;
     for(int i = 0;i < contextSelection.Count;i++) {
         contextSelection[i] += offset;
     }
     // shift all keys on all tracks
     foreach(AMTrack track in take.trackValues) {
         if(track.id == _track.id) continue;
         track.offsetKeysFromBy(itarget, 0, offset);
     }
 }
Ejemplo n.º 5
0
        // select a track by index
        public void selectTrack(AMTakeData take, int index, bool isShiftDown, bool isControlDown)
        {
            bool isInContextSelection = contextSelectionTracks.Contains(index);
            if(!isShiftDown && !isControlDown) {
                if(selectedTrack != index) {
                    selectedTrack = index;
                    if(!isInContextSelection) {
                        // clear context selection
                        contextSelection = new List<int>();
                        contextSelectionTracks = new List<int>();
                    }
                }
                if(index > -1) selectGroup(take, take.getTrackGroup(index), false, false, true);
            }

            if(!isInContextSelection)
                contextSelectionTracks.Add(index);
            else if(isControlDown && selectedTrack != index && !isShiftDown) {
                contextSelectionTracks.Remove(index);
            }
            // select range
            if((selectedTrack != -1 || selectedGroup != 0) && isShiftDown) {
                List<int> range = take.getTrackIDsForRange((selectedTrack != -1 ? selectedTrack : selectedGroup), index);
                foreach(int track_id in range) {
                    if(!contextSelectionTracks.Contains(track_id)) contextSelectionTracks.Add(track_id);
                }
            }
        }
Ejemplo n.º 6
0
 public void selectGroup(AMTakeData take, int group_id, bool isShiftDown, bool isControlDown, bool softSelect = false)
 {
     if(isShiftDown || isControlDown) {
         contextSelectGroup(take, group_id, isControlDown);
         // select range
         if((selectedTrack != -1 || selectedGroup != 0) && isShiftDown) {
             List<int> range = take.getTrackIDsForRange((selectedTrack != -1 ? selectedTrack : selectedGroup), group_id);
             foreach(int track_id in range) {
                 if(!contextSelectionTracks.Contains(track_id)) contextSelectionTracks.Add(track_id);
             }
         }
     }
     else if(!softSelect) {
         if(contextSelectionTracks.Count == 1) contextSelectionTracks = new List<int>();
     }
     selectedGroup = group_id;
 }
Ejemplo n.º 7
0
	    /*public bool setShowWarningForLostReferences(bool showWarningForLostReferences) {
	        if(this.showWarningForLostReferences != showWarningForLostReferences) {
	            this.showWarningForLostReferences = showWarningForLostReferences;
	            return true;
	        }
	        return false;
	    }*/

	    public void DeleteAllTakesExcept(AMTakeData take) {
	        List<AMTakeData> _t = takes;
	        for(int index = 0; index < _t.Count; index++) {
	            if(_t[index] == take) continue;
	            DeleteTake(index);
	            index--;
	        }
	    }
Ejemplo n.º 8
0
	    public int GetTakeIndex(AMTakeData take) {
	        List<AMTakeData> _t = takes;
	        for(int i = 0; i < _t.Count; i++) {
	            if(_t[i] == take)
	                return i;
	        }
	        return -1;
	    }
Ejemplo n.º 9
0
 public bool isGroupSelected(AMTakeData take, int group_id, ref int numTracks)
 {
     AMGroup grp = take.getGroup(group_id);
     for(int i = 0;i < grp.elements.Count;i++) {
         // select track
         if(grp.elements[i] > 0) {
             if(!contextSelectionTracks.Contains(grp.elements[i])) return false;
             numTracks++;
         }
         else {
             if(isGroupSelected(take, grp.elements[i], ref numTracks) == false) return false;
         }
     }
     return true;
 }
Ejemplo n.º 10
0
 public AMTrack getSelectedTrack(AMTakeData take)
 {
     if(selectedTrack == -1) return null;
     int ind = take.getTrackIndex(selectedTrack);
     return ind == -1 || ind >= take.trackValues.Count ? null : take.trackValues[ind];
 }
Ejemplo n.º 11
0
 public int[] getKeyFramesInGhostSelection(AMTakeData take, int startFrame, int endFrame, int track_id)
 {
     List<int> key_frames = new List<int>();
     if(track_id <= -1) return key_frames.ToArray();
     foreach(AMKey key in take.getTrack(track_id).keys) {
         if(key.frame + ghost_selection_total_offset < startFrame) continue;
         if(key.frame + ghost_selection_total_offset > endFrame) break;
         if(isFrameInContextSelection(key.frame)) key_frames.Add(key.frame + ghost_selection_total_offset);
     }
     return key_frames.ToArray();
 }
Ejemplo n.º 12
0
 public void deleteSelectedGroup(AMTakeData take, bool deleteContents, ref List<MonoBehaviour> modifiedItems)
 {
     take.deleteGroup(selectedGroup, deleteContents, ref modifiedItems);
     // select root group
     selectedGroup = 0;
 }
Ejemplo n.º 13
0
 public bool contextSelectionHasKeys(AMTakeData take)
 {
     AMTrack track = getSelectedTrack(take);
     if(track) {
         foreach(AMKey key in track.keys) {
             for(int i = 0;i < contextSelection.Count;i += 2) {
                 // if selection start frame > frame, break out of sorted list
                 if(contextSelection[i] > key.frame) break;
                 if(contextSelection[i] <= key.frame && contextSelection[i + 1] >= key.frame) return true;
             }
         }
     }
     return false;
 }
Ejemplo n.º 14
0
 /*public void contextSelectGroup(int group_id, bool deselect) {
     AMGroup grp = getGroup(group_id);
     for(int i=0;i<grp.elements.Count;i++) {
         // select track
         if(grp.elements[i] > 0) {
             bool isSelected = contextSelectionTracks.Contains(grp.elements[i]);
             if(deselect) {
                 if(isSelected) contextSelectionTracks.Remove(grp.elements[i]);
             } else {
                 if(!isSelected) contextSelectionTracks.Add(grp.elements[i]);
             }
         } else {
             contextSelectGroup(grp.elements[i],deselect);
         }
     }
 }*/
 public void contextSelectGroup(AMTakeData take, int group_id, bool isControlDown)
 {
     AMGroup grp = take.getGroup(group_id);
     int numTracks = 0;
     bool deselect = isControlDown && isGroupSelected(take, group_id, ref numTracks);
     for(int i = 0;i < grp.elements.Count;i++) {
         // select track
         if(grp.elements[i] > 0) {
             bool isSelected = contextSelectionTracks.Contains(grp.elements[i]);
             if(deselect) {
                 if(isSelected) contextSelectionTracks.Remove(grp.elements[i]);
             }
             else {
                 if(!isSelected) contextSelectionTracks.Add(grp.elements[i]);
             }
         }
         else {
             contextSelectGroup(take, grp.elements[i], deselect);
         }
     }
 }
Ejemplo n.º 15
0
	    public static void SetDirtyTracks(AMTakeData take) {
	        foreach(AMTrack track in take.trackValues) {
	            EditorUtility.SetDirty(track);
	        }
	    }
Ejemplo n.º 16
0
	    public AMTakeData AddNewTake() {
	        string name = "Take" + (takes.Count + 1);
	        AMTakeData a = new AMTakeData();
	        // set defaults
	        a.name = name;
	        MakeTakeNameUnique(a);

	        takes.Add(a);

	        return a;
	    }
Ejemplo n.º 17
0
        /*public AMKey[] getContextSelectionKeys() {
            List<AMKey> keys = new List<AMKey>();
            foreach(AMKey key in getSelectedTrack().keys) {
                for(int i=0;i<contextSelection.Count;i+=2) {
                    // if selection start frame > frame, break out of sorted list
                    if(contextSelection[i] > key.frame) break;
                    if(contextSelection[i] <= key.frame && contextSelection[i+1] >= key.frame) keys.Add(key);
                }
            }
            return keys.ToArray();
        }*/
        // offset context selection frames by an amount. can be positive or negative
        //returns keys that are to be deleted
        public AMKey[] offsetContextSelectionFramesBy(AMTakeData take, AMITarget itarget, int offset)
        {
            if(offset == 0) return new AMKey[0];
            if(contextSelection.Count <= 0) return new AMKey[0];

            List<AMKey> rkeys = new List<AMKey>();
            List<AMKey> keysToDelete = new List<AMKey>();

            foreach(int track_id in contextSelectionTracks) {
                bool shouldUpdateCache = false;
                AMTrack _track = take.getTrack(track_id);
                foreach(AMKey key in _track.keys) {
                    for(int i = 0;i < contextSelection.Count;i += 2) {
                        // move context selection
                        if(contextSelection[i] <= key.frame && contextSelection[i + 1] >= key.frame) {
                            // if there is already a key in the new frame position, mark for deletion
                            bool keyToOverwriteInContextSelection = false;
                            if(_track.hasKeyOnFrame(key.frame + offset)) {
                                // check if the key is in the selection
                                for(int j = 0;j < contextSelection.Count;j += 2) {
                                    if(contextSelection[j] <= (key.frame + offset) && contextSelection[j + 1] >= (key.frame + offset)) {
                                        keyToOverwriteInContextSelection = true;
                                        break;
                                    }
                                }
                                // if not key is not in selection, mark for deletion
                                if(!keyToOverwriteInContextSelection) keysToDelete.Add(_track.getKeyOnFrame(key.frame + offset));
                            }
                            key.frame += offset;
                            if(!shouldUpdateCache) shouldUpdateCache = true;
                            break;
                        }
                    }

                }

                // delete keys that were overwritten
                foreach(AMKey key in keysToDelete) {
                    _track.keys.Remove(key);
                    rkeys.Add(key);
                }
                keysToDelete.Clear();

                // update cache
                if(shouldUpdateCache) {
                    _track.updateCache(itarget);
                }
            }
            // update context selection
            for(int i = 0;i < contextSelection.Count;i++) {
                // move context selection
                contextSelection[i] += offset;
            }
            // clear ghost selection
            ghostSelection = new List<int>();

            return rkeys.ToArray();
        }
Ejemplo n.º 18
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.numFrames = dupTake.numFrames;
	        a.startFrame = dupTake.startFrame;
	        //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);
	    }
Ejemplo n.º 19
0
        public AMKey[] removeSelectedKeysFromTrack(AMTakeData take, AMITarget itarget, int track_id)
        {
            List<AMKey> dkeys = new List<AMKey>();

            bool didDeleteKeys = false;
            AMTrack track = take.getTrack(track_id);
            for(int i = 0;i < track.keys.Count;i++) {
                if(!isFrameInContextSelection(track.keys[i].frame)) continue;
                dkeys.Add(track.keys[i]);
                track.keys.Remove(track.keys[i]);
                i--;
                didDeleteKeys = true;
            }
            if(didDeleteKeys) track.updateCache(itarget);

            return dkeys.ToArray();
        }
Ejemplo n.º 20
0
	    public void MakeTakeNameUnique(AMTakeData take) {
	        bool loop = false;
	        int count = 0;
	        do {
	            if(loop) loop = false;
	            foreach(AMTakeData _take in takes) {
	                if(_take != take && _take.name == take.name) {
	                    if(count > 0) take.name = take.name.Substring(0, take.name.Length - 3);
	                    count++;
	                    take.name += "(" + count + ")";
	                    loop = true;
	                    break;
	                }
	            }
	        } while(loop);
	    }
Ejemplo n.º 21
0
        //frames
        // select a frame
        public void selectFrame(AMTakeData take, int track, int num, float numFramesToRender, bool isShiftDown, bool isControlDown)
        {
            selectedFrame = num;
            selectTrack(take, track, isShiftDown, isControlDown);

            if((selectedFrame < take.startFrame) || (selectedFrame > take.endFrame)) {
                take.startFrame = selectedFrame;
                take.endFrame = take.startFrame + (int)numFramesToRender - 1;
            }
            take.selectedFrame = selectedFrame;
        }
Ejemplo n.º 22
0
	    public List<GameObject> GetDependencies(AMTakeData take = null) {
	        // if only one take
	        if(take != null) return take.getDependencies(mDataTarget);

	        // if all takes
	        List<GameObject> ls = new List<GameObject>();
	        foreach(AMTakeData t in takes) {
	            ls = ls.Union(t.getDependencies(mDataTarget)).ToList();
	        }
	        return ls;
	    }
Ejemplo n.º 23
0
        /// <summary>
        /// Only call this during OnDestroy
        /// </summary>
        public void Destroy()
        {
            if(mSequence != null) {
                HOTween.Kill(mSequence);
                mSequence = null;
            }

            mActionTween = null;

            mTarget = null;
            mTake = null;
        }