【轉載】UGUI動畫

來源:互聯網
上載者:User

標籤:

原文連結:http://blog.sina.com.cn/s/blog_89d90b7c0102vi4y.html

Unity暫時沒有單獨給UGUI提供動畫系統,用官方的動畫系統也能做只是比較麻煩,所以我們有很多選擇了。

1.修改NGUI的UITweener在用UGUI上,輕量級動畫系統。

2.使用第三方外掛程式入iTween,DoTween,HOTween等。

 

發現DoTween不錯,就試試了。

先來看:


這裡用到了位置,旋轉,縮放,顏色四個最主要的動畫效果,暫時簡單寫一個例子,以便以後使用時查閱。

和詳細使用說明如下。

:http://dotween.demigiant.com/download.php

文檔地址:http://dotween.demigiant.com/documentation.php

下載之後複製到工程目錄,VS引用DOTween.dll,代碼引用using DG.Tweening即可。

 

demo代碼如下:

using UnityEngine;  using System.Collections;  using UnityEngine.UI;  using DG.Tweening;     public class UIFirstAnima : MonoBehaviour   {      private Tweener m_pos;      private Tweener m_rota;      private Tweener m_scale;      private Tweener m_color;      void Start () {          // 全域初始化          DOTween.Init(true, true, LogBehaviour.ErrorsOnly).SetCapacity(200, 10);          Image image = transform.GetComponent();          // 位置          m_pos = image.rectTransform.DOMove(new Vector3(Screen.width * 0.5f, Screen.height * 0.5f,0), 1f);          m_pos.SetEase(Ease.OutCubic);          m_pos.SetLoops(10,LoopType.Yoyo);          // 旋轉          m_rota = image.rectTransform.DORotate(new Vector3(0,180,0), 1);          m_rota.SetEase(Ease.Linear);          m_rota.SetLoops(10, LoopType.Yoyo);          // 縮放          m_scale = image.rectTransform.DOScale(new Vector3(0.6f, 0.6f, 1f), 1);          m_scale.SetEase(Ease.Linear);          m_scale.SetLoops(10, LoopType.Yoyo);          // 顏色          m_color = image.material.DOColor(new Color(0f,1f,1f, 0.7f), 1f);          m_color.SetEase(Ease.Linear);          m_color.SetLoops(10, LoopType.Yoyo);          // 註冊開始和結束事件          m_pos.OnStart(AnimaStart);          m_pos.OnComplete(AnimaEnd);      }      private void AnimaStart()      {          Debug.Log("動畫開始");      }      private void AnimaEnd()      {          Debug.Log("動畫結束");      }  }  

  

【轉載】UGUI動畫

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.