本来想要Sequence重复播放,大概思路如下:
1.先创建一个空的Sequence对象
Sequence Squence_detail_show;
2.然后在star中将这个空对象赋予一个??Dotween的sequence对象,设置autokill为false,且动画暂停
Squence_detail_show = DOTween.Sequence();//创建一个动画序列对象。
Squence_detail_show.AppendInterval(1f);
Squence_detail_show.Append(camara_transform.DOLocalMove(new Vector3(-0.6339f, 1.2872f, -0.0463f), 2f).OnKill(()=>print("一个子对象被杀死")).SetAutoKill(false));//镜头位移 1
Squence_detail_show.Append(jia2ju4_transform_1.DOLocalMove(new Vector3(5f, 1.95f, 0), 1)); //夹具1展开,
Squence_detail_show.Join(jia2ju4_transform_2.DOLocalMove(new Vector3(-2.14f, 1.95f, 3.88f), 1)); //夹具2展开,
Squence_detail_show.Join(jia2ju4_transform_3.DOLocalMove(new Vector3(-2.08f, 1.95f, -3.65f), 1)); //夹具3展开,
Squence_detail_show.AppendInterval(1f);
Squence_detail_show.Append(jia2ju4_transform_1.DOLocalMove(new Vector3(2.63f, 1.95f, 0), 1)); //夹具返回原位,
Squence_detail_show.Join(jia2ju4_transform_2.DOLocalMove(new Vector3(-1.22f, 1.95f, 2.29f), 1)); //夹具返回原位,
Squence_detail_show.Join(jia2ju4_transform_3.DOLocalMove(new Vector3(-1.27f, 1.95f, -2.24f), 1)); //夹具返回原位,
/旋转的增量模式,以后统统用这个
Squence_detail_show.Append(jia2zuo4_transform.DOLocalRotate(new Vector3(720, 0, 0), 1).SetRelative(true).SetEase(Ease.Linear));//夹座旋转,
Squence_detail_show.AppendInterval(1f);
Squence_detail_show.Append(camara_transform.DOLocalMove(new Vector3(-0.636f, 1.3772f, -0.1404f), 2f));//镜头位移 2
Squence_detail_show.Append(dao1ju4jia2zuo4_transform.DOLocalMove(new Vector3(0, 0, -5), 1).SetRelative(true)); //上刀具 夹座
Squence_detail_show.Append(dao1ju4jia2zuo4_transform.DOLocalMove(new Vector3(0, 0, 5), 1).SetRelative(true)); //上刀具 夹座,返回动作
Squence_detail_show.Append(camara_transform.DOLocalMove(Vector3_camara_main, 2f));//镜头位移 复位
Squence_detail_show.SetEase(Ease.Linear).SetAutoKill(false).Pause().OnComplete(()=>print("动画1播放完毕")).
OnPlay(()=>print("动画序列1正在播放。"))
;
3.最后用一个click事件去触发这个sequence的播放
public void Clickde() {
if (Squence_detail_show.IsPlaying()==true)
{
print("等待斑驳播放完毕。");
return;
}
else
{
print("点击播放");
Squence_detail_show.Play();
Squence_detail_show.PlayForward();
}
问题是,动画只能播放一次,想尽方法都不能让动画重复播放,也搞不清楚里面的机理是什么。
5.最后的解决方法便是,只能播放一次动画就重新创建一个sequence了,让这些动画去被系统自动回收,大概就是这样子,每被click触发一下就重新创建一个sequence。
public void Clicked() {
sequence = DOTween.Sequence();
sequence.Append(transform.DOLocalMove(new Vector3(0, 0, 4), 1).OnPlay(()=>print("返回原位。")));
sequence.Append(transform.DOLocalMove(new Vector3(6, 0, 4), 1));
sequence.Append(transform.DOLocalMove(new Vector3(2, 0, 6), 1));
}
如果有懂的,还望赐教。
|