您的位置:首页 > 移动开发 > Unity3D

Unity 实现按钮点击 某物体缓慢放大效果 比如打开商店

2017-08-01 19:48 2176 查看
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class ButtonOnclick : MonoBehaviour {
    public AnimationCurve curve;//放大的曲线
    public Button But;
    private float value = 0;
    // Update is called once per frame
    void Start () {
        But.onClick.AddListener (delegate {
            if(this.gameObject.activeSelf==true){
                StartCoroutine (buttonAnimation());
            }
        });
    }
    IEnumerator buttonAnimation(){
        value = 0;
        while (true) {
            this.transform.localScale=Vector3.one*curve.Evaluate (value+=Time.deltaTime*2);
            yield return null;
            if (value>=1) {
                break;
            }
        }
    }
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: