Unity_DOTween动画的学习(三)_Sequence的示例演示

来源:互联网 发布:python 远程ssh 编辑:程序博客网 时间:2024/05/18 02:10

Unity_DOTween动画的学习(三)_Sequence的示例演示<23/9/2017>

0.Append(插入动画,太简单,请参考下面几种模式理解)

1.从上到下执行;

2.剪切的Getcomponent可能会导致报错,最好用手重新打一遍;

3.回调最好插入匿名方法,Interval都是对应类型插入等待时间;




1.Insert示例:


using System.Collections;using System.Collections.Generic;using UnityEngine;using DG.Tweening;using UnityEngine.UI;public class TweenTest : MonoBehaviour{    public GameObject a;    private Sequence mySequence;    public void Click0()    {        //Insert动画插入,并行效果演示,Insert(等待执行时间,目标动画)        mySequence = DOTween.Sequence().Append(a.transform.DOMove(new Vector3(-4, -4, -4), 3f))            .Insert(0, a.GetComponent<MeshRenderer>().material.DOColor(Color.black, 0.5f));    }}



回调函数,好好使用各种方法,不要乱搞,会出问题的:

using System.Collections;using System.Collections.Generic;using UnityEngine;using DG.Tweening;using UnityEngine.UI;public class TweenTest : MonoBehaviour{    public GameObject a;    private Sequence mySequence;    public void Click0()    {        //prepend将当前动画插到该Sequence的最前面,如下两个prepend越靠近句末越先播放        //Insert动画的执行顺序是该从下到上(语句的从后往前)的方式实现的,Append从上到下        mySequence = DOTween.Sequence()            .Append(a.transform.DOMove(new Vector3(-4, -4, -4), 1f))            .Insert(0, a.transform.DOLocalRotate(new Vector3(0, 1000, 0), 5f, RotateMode.LocalAxisAdd).SetLoops(-1, LoopType.Incremental).SetEase(Ease.Linear))            .InsertCallback(1f, () => { a.GetComponent<MeshRenderer>().material.DOColor(new Color(0, 0, 0), 1f); })//此处剪切可能会报错不包含.material定义,重新打一遍就好了            .Append(a.transform.DOMove(new Vector3(4, 4, 4), 1f));    }}


2.Join示例:(和Insert非常相似,但是参数不同,不可直接控时)


演示一:

using System.Collections;using System.Collections.Generic;using UnityEngine;using DG.Tweening;using UnityEngine.UI;public class TweenTest : MonoBehaviour{    public GameObject a;    private Sequence mySequence;    public void Click0()    {        //Join伴随其上方的动画同时执行,Join(目标动画)        mySequence = DOTween.Sequence()            .Append(a.transform.DOMove(new Vector3(-4, -4, -4), 2f))            .Insert(0, a.GetComponent<MeshRenderer>().material.DOColor(Color.black, 1f))            .Append(a.transform.DOMove(new Vector3(4, 4, 4), 2f))            .Join(a.GetComponent<MeshRenderer>().material.DOColor(Color.blue, 1f));    }}

演示二:(对演示一的理解补充)

using System.Collections;using System.Collections.Generic;using UnityEngine;using DG.Tweening;using UnityEngine.UI;public class TweenTest : MonoBehaviour{    public GameObject a;    private Sequence mySequence;    public void Click0()    {        mySequence = DOTween.Sequence()            .Append(a.transform.DOMove(new Vector3(-4, -4, -4), 2f))            .Join(a.GetComponent<MeshRenderer>().material.DOColor(Color.blue, 1f))            .Append(a.transform.DOMove(new Vector3(4, 4, 4), 2f))            .Append(a.transform.DOScaleX(3, 1f).SetEase(Ease.OutCirc).SetLoops(2, LoopType.Yoyo));//偶数Yoyo才会回到原始大小    }}


4.Prepend示例:

using System.Collections;using System.Collections.Generic;using UnityEngine;using DG.Tweening;using UnityEngine.UI;public class TweenTest : MonoBehaviour{    public GameObject a;    private Sequence mySequence;    public void Click0()    {        //prepen将当前动画插入到该动画的最前面,如下两个prepend越靠近句末的插入的顺序越靠前        mySequence = DOTween.Sequence()            .Append(a.transform.DOMove(new Vector3(-4, -4, -4), 2f))            .Append(a.transform.DOMove(new Vector3(4, 4, 4), 2f))            .Prepend(a.transform.DOMove(new Vector3(0, 0, -4), 2f))            .Prepend(a.transform.DOMove(new Vector3(0, 0, 4), 2f));    }}


using System.Collections;using System.Collections.Generic;using UnityEngine;using DG.Tweening;using UnityEngine.UI;public class TweenTest : MonoBehaviour{    public GameObject a;    private Sequence mySequence;    public void Click0()    {        //prepend将当前动画插到该Sequence的最前面,如下两个prepend越靠近句末越先播放        //动画的执行顺序是该从下到上(语句的从后往前)的方式实现的        mySequence = DOTween.Sequence()            .Append(a.transform.DOMove(new Vector3(-4, -4, -4), 1f))            .Append(a.transform.DOMove(new Vector3(4, 4, 4), 1f))            .Prepend(a.transform.DOMove(new Vector3(0, 0, -3), 1f))            //1.该回调后面的sequence动画会在一帧内被立即执行完,不会激活当前受影响动画的时间控制效果(使用存疑)            //2.该回调与prepend同类型存在执行顺序影响,其他类型无影响            //3.该回调主要是用来调用方法的            .PrependCallback(() => { a.transform.DOMove(new Vector3(0, 0, 0), 1f); })            .Prepend(a.transform.DOMove(new Vector3(0, 0, 3), 1f));    }}



主要就是暂停几秒的prepend形式插入:

using System.Collections;using System.Collections.Generic;using UnityEngine;using DG.Tweening;using UnityEngine.UI;public class TweenTest : MonoBehaviour{    public GameObject a;    private Sequence mySequence;    public void Click0()    {        //prepend将当前动画插到该Sequence的最前面,如下两个prepend越靠近句末越先播放        //动画的执行顺序是该从下到上(语句的从后往前)的方式实现的        mySequence = DOTween.Sequence()            .Append(a.transform.DOMove(new Vector3(-4, -4, -4), 1f))            .Append(a.transform.DOMove(new Vector3(4, 4, 4), 1f))            .PrependInterval(3f)//先把下面插入的播放,到我这里暂停,然后回到第一个Append往下按顺序播放            .Prepend(a.transform.DOMove(new Vector3(0, 0, -3), 1f))            .Prepend(a.transform.DOMove(new Vector3(0, 0, 3), 1f));    }}




阅读全文
1 0
原创粉丝点击