DOTween -Tweener 特定設置

DOTween是一個動畫過渡插件,用起來很方便。
官方文檔:http://dotween.demigiant.com/documentation.php#options

  • SetDelay(float);
    在tween 執行前,會先執行SetDelay()函數;
    舉例:一個物體移動到另一個位置
    public Transform goObj;
    public Transform toObj;
goObj.transform.DOMove(toObj.transform.position,1.5f).SetDelay(2f);
// 先等待2秒,goObj移動到toObj, 移動過去用時1.5秒。
  • From(bool Relative = false.);
    這麼解釋呢 它就是替代前面的Tween
    relative = true, 移動位置相對位置,以當前物體位置來設置相對位置
這裏寫代碼片
舉例:一個物體移動到另一個位置

obj.transform.DOMove(new Vector3(-2, 0, 0), 2f).From(true);
// obj.transform.position 位置爲(2,0,0),from(true),物體就會從(0,0,0)移向座標位置(2,0,0)。from(false) 物體會從(-2,0,0)移向(2,0,0)

   public Transform goObj;
   public Transform toObj;
    void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
           goObj.transform.DOMove(toObj.transform.position, 1f)
           .SetLoops(1,LoopType.Yoyo).From().SetDelay(2f);
        }
// 效果就是小夥子移動過去親一下,等2秒,小子又跑了,哈哈好壞。
SetDelay()函數已經解釋過了 它會在前面一個Tween執行前先執行,而From()是代替前面Tween並且立刻從toObj位置移動到goObj位置,哎 說的自己都不知道是什麼 新來的,看效果說話。

//=========今天先寫個函數的用法會隨時更新DOTween用法==========//

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章