Examples of the use of plug-ins DOTween

Disclaimer: This article is a blogger original article, shall not be reproduced without the bloggers allowed. https://blog.csdn.net/lxt610/article/details/85346430


1 Introduction

  For two years of cocos game, now return to the embrace of unity! Feel at home, just a lot of things for a long time without a little rusty! I decided to conduct a review here, but also a summary! Interested small partners with the view of it, experts do not like do not spray, omissions, but also look correction. The following work together to understand it ~

2. Download

  Description: DoTween animation as a plug-in, formerly known as HOTween, visual editing support for 2D and 3D scenes.
Plug-in can store to buy resources, both free version and the paid version (Pro version). Here we offer a Pro version!

3, using

  Animation DoTween suitable for 2D and 3D . And DoTween with other animation plug-ins (such as: itween, hotween, dotween) compared to its efficiency is the highest, on DoTween flexibility, stability, ease of use are very prominent ! This paper give some examples of use, detailed not say it! Details, after reading this article you can leave comments. This article will in the future work and study supplemented from time to time update, well we quickly import packages to play with it:

3.1, an aid to understanding

Easing function to preview samples
easing functions
some explanation easing function of Microsoft

3.2, introduce common API

Using this plug-in requires references using DG.Tweening

Common methods:

To DO method beginning with: fill method among animation. For example: Transform.DOMoveX (10,1)
to Set method beginning with: setting tween property. For example: Tweener.SetLoops (4, LoopType.Yoyo)
to On method beginning: make the callback function between animation. For example: Tweener.OnStart (callBackFunction)

3.2.1, DOFade () gradient transparency

Here Insert Picture Description

/// <summary>
/// 将目标的alpha渐变为给定值。
/// </summary>
/// <param name="endValue">目标值</param>
/// <param name="duration">持续时间</param>
DOFade(float endValue, float duration)

Example of use (Effects above):

public void Change()
{
	img.DOFade(0.8f, 1.0f);		//image组件
	txt.DOFade(0.35f, 1.0f);	//Text组件
}

public void MyReset()
{
     txt.DOFade(1.0f, 1.0f);
     img.DOFade(0.2f, 0f);
 }

It can also be used AudioSource

3.2.2、DOText

You can make a similar effect print: The
Here Insert Picture Description
code is as follows:

public void PrintEffect()
{
	Text txt = GameObject.Find("TextTest").GetComponent<Text>();
    	txt.DOText("云想衣裳花想容,春风拂槛露华浓。\n若非群玉山头见,会向瑶台月下逢。", 3f);
	//txt.DOText("云想衣裳花想容,春风拂槛露华浓。\n若非群玉山头见,会向瑶台月下逢。", 3f).SetLoops(-1);//SetLoops可以设置循环次数,其中-1表示无限重复
}

DOText (string endValue, float duration), which supports rich text parameters endValue

3.2.12, using for example

Here Insert Picture Description
This is a simple to use, as shown in FIG effect, as follows:

public void Test()
{
	StartCoroutine(MoveAction());
}

IEnumerator MoveAction()
{
	GameObject content = GameObject.Find("Scroll View/Viewport/Content").gameObject;
	foreach (Transform child in content.transform)
	{
		child.DOLocalMoveX(-1000, 0.5f, false).From().SetEase(Ease.OutBack);
		yield return new WaitForSeconds(0.02f);
	}
}

4 Conclusion

The End
  Well, today's share on here, if inadequacies also hope you correct me in time, feel free to discuss the exchange! ! !

Guess you like

Origin blog.csdn.net/lxt610/article/details/85346430