Unity NGUI TWEEN

发布时间:2020-06-29 23:32:30 作者:Aonaufly
阅读:1067
开发者专用服务器限时活动,0元免费领! 查看>>

大家都知道NGUI中自带了缓动(Tween),我一开始使用的时候,只能让他缓动1次。这里面有一个UIPlayTween可以帮你多次的运行Tween。当然,你可以借助DOTween , ITween等专业的第三方缓动插件。本篇文章只讲解: NGUI的Tween

首先对栗子进行一些简单的讲解:

主要是对“目标GO”进行位移操作

Unity NGUI TWEEN

对于“目标GO”需要挂载:TweenPosition , UIPlayTween , 还有我自己的一个脚本 : TestTweenPos(只要是操作TweenPosition,UIPlayTween)

关于 : TweenPosition:

Unity NGUI TWEEN

关于 UIPlayTween:

Unity NGUI TWEEN

关于 TestTweenPos:

Unity NGUI TWEEN

有2个参数 : 分别是上面的TweenPosition和UIPlayTween

上 TestTweenPos代码 :

using UnityEngine;
using System.Collections;

public class TestTweenPos : MonoBehaviour {

	// Use this for initialization
    public TweenPosition _tweenPos;
    public UIPlayTween _playTween;
    private bool _isRe = false;
	void Start () {
	
	}
	
	// Update is called once per frame
	void Update () {
	
	}

    public void StartTween( Vector2 _location )
    {
        if( !this._isRe)
        {
            this._tweenPos.from = new Vector3(this.gameObject.transform.localPosition.x, this.gameObject.transform.localPosition.y, 0);
            this._tweenPos.to = new Vector3(_location.x, _location.y, 0.0f);
        }
        else
        {
            this._tweenPos.to = new Vector3(this.gameObject.transform.localPosition.x, this.gameObject.transform.localPosition.y, 0);
            this._tweenPos.from = new Vector3(_location.x, _location.y, 0.0f);
        }
        this._isRe = !this._isRe;
        this._playTween.Play(true);
    }
}

亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>

推荐阅读:
  1. unity3d中的ngui的一些笔记
  2. 如何基于Python实现自动扫雷

开发者交流群:

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

tween ngui un

上一篇:cmp bne 以及sub指令的详解

下一篇:关于ModuleNotFoundError: No module named 'urllib3'解决

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》
开发者交流群×