public void PlayAtTime(int index, float time, bool loop = false) { if (mNowPlayingTakeIndex == index) { return; } mLastPlayingTakeIndex = mNowPlayingTakeIndex; Pause(); if (mLastPlayingTakeIndex != -1) { sequenceCtrls[mLastPlayingTakeIndex].take.PlaySwitch(this); //notify take that we are switching } SequenceControl amSeq = sequenceCtrls[index]; Take newPlayTake = amSeq.take; Sequence seq = amSeq.sequence; if (seq == null) { amSeq.Build(sequenceKillWhenDone, updateType, updateTimeIndependent); seq = amSeq.sequence; } mNowPlayingTakeIndex = index; newPlayTake.PlayStart(this, newPlayTake.frameRate * time, 1.0f); //notify take that we are playing if (seq != null) { /*if(loop) { * seq.loops = -1; * } * else { * seq.loops = newPlayTake.numLoop; * }*/ seq.timeScale = mAnimScale; seq.Goto(time, true); } }
/// <summary> /// Go to a given time without playing. /// </summary> public void Goto(int takeIndex, float time) { Sequence seq; if (mNowPlayingTakeIndex != takeIndex) { mLastPlayingTakeIndex = mNowPlayingTakeIndex; Pause(); if (mLastPlayingTakeIndex != -1) { sequenceCtrls[mLastPlayingTakeIndex].take.PlaySwitch(this); //notify take that we are switching } SequenceControl amSeq = sequenceCtrls[takeIndex]; amSeq.isForcedLoop = false; Take newPlayTake = amSeq.take; seq = amSeq.sequence; if (seq == null) { amSeq.Build(sequenceKillWhenDone, updateType, updateTimeIndependent); seq = amSeq.sequence; } mNowPlayingTakeIndex = takeIndex; newPlayTake.PlayStart(this, newPlayTake.frameRate * time, 1.0f); //notify take that we are playing } else { seq = sequenceCtrls[takeIndex].sequence; } if (seq != null) { seq.Goto(time); } }