DoTween

dotween最原始的用法
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using DG.Tweening;

public class DotweenText : MonoBehaviour {
    public GameObject cube;
    public RectTransform rectTransform;
    Vector3 MyValue = new Vector3(10,0,0);
    float x = 0;
    // Use this for initialization
    void Start () {
        // DOTween.To(()=>MyValue,pos=>MyValue=pos,new Vector3(10,10,2),5);
        //对当前变量坐标pos的动画改变得插值,只是对x的一个改变,而MyValue表示的是一个返回值,x表示的事差值
        // DOTween.To(()=>x,num=>x=num,10,5);//最原始的Dotween用法可以操作各种值
        DOTween.To(()=> MyValue,vec=>MyValue=vec,new Vector3(0,0,0),5);
    }
    
    // Update is called once per frame
    void Update () {
        // print(x);
        // cube.transform.position = MyValue;//赋值给当前位置
       // rectTransform.position = MyValue;//世界坐标的0,0,0
        rectTransform.localPosition = MyValue;//局部坐标0,0,0

    }
}
***************************
using UnityEngine;
2
using System.Collections;
3
using DG.Tweening;//引入DoTween命名空间
4
public class GameStart : MonoBehaviour
5
{
67
    public Vector3 myValue = new Vector3(0, 0, 0);
8
    void Start()
9
    {
10
        //对变量做一个动画,通过插值的方式去修改一个值的变化
11
        DOTween.To(() => myValue, x => myValue = x, new Vector3(10, 0, 0), 2);//用两秒的时间从0,0,0变化到10,10,10
12
         //()=> myValue,表示返回值为myValue,x=>myValue=x,表示将系统计算好的x值(当前值到目标值的插值)赋给myValue,new Vector3(10,0,0),表示达到的目标值,2表示所需时间
13
    }
***************************
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using DG.Tweening;

public class DoMoveText : MonoBehaviour {
    // RectTransform rt;
    // Use this for initialization
    bool b = false;
    void Start () {
        //  rt.DOMove(new Vector3(0,0,0),5);//移动到世界坐标原点
        // rt.DOLocalMove(Vector3.zero,5);//本地坐标原点
        // rt.DOLocalMoveX(0,5);
        Tweener t =  transform.DOLocalMove(Vector3.zero,5);//动画播放完默认自动销毁
        t.SetAutoKill(false);//动画不销毁
    }
    public void PlayTweener() {
        if (b)
        {
            transform.DOPlayForward();
        }
        else
        {
        transform.DOPlayBackwards();

        }
        b = !b;

    }
    
    // Update is called once per frame
    void Update () {
        
    }
}
*****************************
//  transform.DOLocalMove(Vector3.zero, 5).From();//从0,0,0的位置移动到当前位置,false为默认选项
       // transform.DOShakePosition(3,Vector3.up);


******************************
dotween字体显示:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using DG.Tweening;

public class Dotween002 : MonoBehaviour {
    public Text text;
    // Use this for initialization
    void Start () {
        text = text.GetComponent<Text>();
        text.DOText("欢迎来到王者荣耀,请选择你的英雄", 5);//使字一个一个的打出
        text.DOColor(Color.green, 7);//颜色渐变
    }

    
    // Update is called once per frame
    void Update () {
        
    }
}

 

转载于:https://www.cnblogs.com/huang--wei/p/9609395.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值