DoTween小结
2016-03-11 11:12 糯米粥 阅读(807) 评论(0) 编辑 收藏 举报1 using UnityEngine; 2 using System.Collections; 3 using DG.Tweening; 4 5 public class GetStart : MonoBehaviour 6 { 7 8 public Vector3 myValue = new Vector3(0, 0, 0); 9 10 public Transform tr; 11 12 bool isIn = false; 13 14 // Use this for initialization 15 void Start() 16 { 17 //DOTween.To(() => { return myValue; }, (x) => { myValue = x; }, new Vector3(10, 10, 10), 2); 18 19 //transform.DOMove(new Vector3(10, 10, 10), 2).OnComplete(()=>{ 20 // transform.GetComponent<MeshRenderer>().material.DOColor(Color.green, 1); 21 //}); 22 23 //DOTween.To(() => myValue, x => myValue = x, new Vector3(0, 0, 0), 1); 24 25 26 Tweener er = tr.DOLocalMove(new Vector3(0, 0, 0), 0.5f); 27 er.SetAutoKill(false); 28 er.Pause(); 29 30 } 31 32 // Update is called once per frame 33 void Update() 34 { 35 //tr.position = myValue; 36 //tr.GetComponent<RectTransform>().localPosition = myValue; 37 38 //Tween t; 39 //t.SetAutoKill(false); //播放完不销毁 40 //tr.DOPlayForward();//回放,向前播放 41 //tr.DOPlayBackwards(); //向后播放 42 43 //t.Pause(); //暂停 44 //t.Play();//播放 45 46 //tr.DOPlay(); //也是播放。来播放对象上的动画,这个只会播放一次 47 } 48 49 public void btnClick() 50 { 51 if (!isIn) 52 { 53 //tr.DOPlay(); 54 tr.DOPlayForward(); 55 isIn = true; 56 } 57 else 58 { 59 isIn = false; 60 //tr.DOLocalMove(new Vector3(552, 0, 0), 0.5f); 61 tr.DOPlayBackwards(); 62 } 63 } 64 }