使用NGUI插件控制 Tween Scale实现动画效果,听起来有点复杂,但是只要理解就会发现也就是几段代码的问题。下面我们就来看看NGUI Tween Scale实现动画效果实现过程吧。
- using UnityEngine;
- using System.Collections;
- public class NewBehaviourScript : MonoBehaviour
- {
- public Transform tweenTarget;
- public float duration = 0.2f;
- public Vector3 a = new Vector3(0,0,0);
- public Vector3 b = new Vector3(200, 200, 0);
- // Use this for initialization
- void Start () {
- a =new Vector3(50, 50, 0);
- Vector3 b = new Vector3(200,200,0);
- }
- // Update is called once per frame
- void Update () {
- }
- void Be()
- {
- TweenScale.Begin(tweenTarget.gameObject, duration, a);
- }
- void Be1()
- {
- TweenScale.Begin(tweenTarget.gameObject, duration, b);
- }
- }
- public GameObject objPanelAvatarSetting;//对象
- public Vector3 a = new Vector3(1f, 1f, 1f);
- public Vector3 b = new Vector3(-2.204684e-05f, -213f, -76.05f);//声明
- //实现代码 利用scale 与position来实现动画
- objPanelAvatarSetting.gameObject.transform.localScale = new Vector3(0, 0, 0);
- TweenScale.Begin(objPanelAvatarSetting.gameObject, 0.5f, a);
- objPanelAvatarSetting.gameObject.transform.localPosition = new Vector3(-175.322f, 121.4104f, -76.05f);
- TweenPosition.Begin(objPanelAvatarSetting.gameObject,0.5f,b);