示例#1
0
 public static TweenPlugElapsed Get()
 {
     if (mInstance == null)
     {
         mInstance = new TweenPlugElapsed();
     }
     return(mInstance);
 }
示例#2
0
        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);
            }
        }