コード例 #1
0
ファイル: AMTakeEdit.cs プロジェクト: igrir/MateAnimator
        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;
        }
コード例 #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.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);
	    }