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;
}
}
}
}
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;
}
}
}
}