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;
}
}
}
}
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;
}
}
}
}
相关文章推荐
- unity 实现了鼠标滚动放大和缩小物体暨拉近拉远相机的效果
- 【cocos2d-x 3D游戏开发】2: 2D基础回顾---理解CCMenu类的实现, 实现点击放大的菜单按钮
- 鼠标点击实现图片的缓慢放大和缓慢缩小
- java在线聊天项目 swt可视化窗口Design 登录框注册按钮点击改变窗口大小——出现注册面板 实现打开登录框时屏幕居中
- Android实现按钮点击效果
- 代码实现Selector按钮点击效果
- js实现图片点击弹出放大效果(无插件)
- jquery 实现 点击按钮后倒计时效果,多用于实现发送手机验证码、邮箱验证码
- 回车直接实现点击某按钮的效果
- 实现点击图片图片放大效果(续)
- vue实现点击图片放大效果
- iOS实现点击微信头像(放大、缩放、保存)效果
- Unity创建按钮点击实现菜单显示和隐藏
- 基于JS+Canves实现点击按钮水波纹效果
- Android中按钮的水波纹点击效果的实现
- 点击按钮,并且实现增加一个按钮的效果 (附效果图)
- 实现点击ComboBox(DBComboBox)按钮下拉出现TreeView效果
- javascript点击按钮实现隐藏显示切换效果