public override void build(SequenceControl seq, Track track, int index, UnityEngine.Object target) { //float sTime = getWaitTime(seq.take.frameRate, 0.0f); Sequence _seq = seq.sequence; AudioSource _src = target as AudioSource; float frameRate = seq.take.frameRate; float frameCount = Mathf.Ceil(audioClip.length * frameRate); if (oneShot) { seq.InsertCallback(this, () => { //don't play when going backwards if (_seq.isBackwards) { return; } _src.pitch = _seq.timeScale; _src.PlayOneShot(audioClip); }); } else { var tweenV = DOTween.To(TweenPlugElapsed.Get(), () => 0f, (t) => { //don't play when going backwards if (_seq.isBackwards) { return; } _src.time = t % audioClip.length; _src.pitch = _seq.timeScale; if ((_src.isPlaying && _src.clip == audioClip)) { return; } _src.loop = loop; _src.clip = audioClip; _src.Play(); }, 0, audioClip.length); tweenV.plugOptions = new TweenPlugElapsedOptions(new TweenPlugElapsedCounter()); seq.Insert(this, tweenV); } }
public override void build(SequenceControl seq, Track track, int index, UnityEngine.Object target) { if (methodName == null) { return; } float duration = 1.0f / seq.take.frameRate; var tgt = target; //set target to component if (cachedComponent) { tgt = cachedComponent; } else if (!string.IsNullOrEmpty(componentType) && tgt is GameObject) { tgt = cachedComponent = ((GameObject)tgt).GetComponent(componentType); } if (!tgt) { if (!string.IsNullOrEmpty(componentType)) { if (target) { Debug.LogWarning(string.Format("Track {0} Key {1}: Component ({2}) missing in {3}.", track.name, index, componentType, target.name)); } else { Debug.LogWarning(string.Format("Track {0} Key {1}: Component ({2}) is missing.", track.name, index, componentType)); } } else { Debug.LogWarning(string.Format("Track {0} Key {1}: Target is missing.", track.name, index)); } return; } //can't send message if it's not a component Component compSendMsg = null; if (useSendMessage) { compSendMsg = tgt as Component; } if (compSendMsg) { if (parameters == null || parameters.Count <= 0) { seq.InsertCallback(this, () => compSendMsg.SendMessage(methodName, null, SendMessageOptions.DontRequireReceiver)); } else { seq.InsertCallback(this, () => compSendMsg.SendMessage(methodName, parameters[0].toObject(seq.target), SendMessageOptions.DontRequireReceiver)); } } else { var method = cachedMethodInfo != null ? cachedMethodInfo : tgt.GetType().GetMethod(methodName, GetParamTypes()); object[] parms = buildParams(seq.target); seq.InsertCallback(this, () => method.Invoke(tgt, parms)); } }