public override void Refresh() { if (audioSource == null || audioSource.clip == null) { return; } base.Refresh(); bool isPlayKey = false; for (int i = soundKeyFrameList.Count - 1; i >= 0; i--) { if (currTime >= soundKeyFrameList[i].time) { if (currKeyFrameIdx != i || currPlayType != soundKeyFrameList[i].playType) { currKeyFrameIdx = i; currPlayType = soundKeyFrameList[i].playType; JudgePlayType(i); } calculateSound(i, currTime); isPlayKey = true; break; } } if (isPlayKey == false) { currKeyFrameIdx = -1; if (audioSource.isPlaying) { audioSource.Stop(); } } }
public override void Refresh() { if (audioSource == null || audioSource.clip == null) { return; } base.Refresh(); bool isPlayKey = false; for (int i = soundKeyFrameList.Count - 1; i >= 0; i--) { if (currTime >= soundKeyFrameList[i].time) { if (currKeyFrameIdx != i || currPlayType != soundKeyFrameList[i].playType) { currKeyFrameIdx = i; currPlayType = soundKeyFrameList[i].playType; JudgePlayType(i); } calculateSound(i, currTime); isPlayKey = true; break; } } if (isPlayKey == false) { currKeyFrameIdx = -1; if(audioSource.isPlaying) { audioSource.Stop(); } } }