unity 鼠标悬停事件
来源:互联网 发布:三方博弈矩阵 编辑:程序博客网 时间:2024/06/08 05:17
笔者在网上发现了,很多种方法 ,当然咱们找最好用的,也简单的 下面废话不多说直接上代码 我在啰嗦几句 第一这个脚本挂在需要相应的游戏体上 第二被挂游戏体必须带有collider, 第三仅仅制作完上面的两步 本应该没有问题,,笔者又发现一个问题 就是只有鼠标在物体的右上方才会很灵敏的相应到 在在左下方反而没什么反应 ,为此笔者在脚本上加上了一句
this.GetComponent<BoxCollider> ().size = new Vector3 (1.5f, 1.5f, 1.5f);原来物体的size 为(1,1,1) 我的目的是加大物体本身的碰撞体 结果顺利的实现了下面是完整using System.Collections;using System.Collections.Generic;using UnityEngine;public class Shubiaoxuanting : MonoBehaviour{bool ischanger;//上移动 0为未上移 1为上移int move_up=0;void Start () {ischanger = false;//扩大碰撞体的尺寸 方便检测鼠标悬停this.GetComponent<BoxCollider> ().size = new Vector3 (1.5f, 1.5f, 1.5f);//给麻将初始状态的位置this.transform.position = new Vector3 (this.transform.position.x, 0, this.transform.position.z);}//鼠标在物体上面引起的动作void OnMouseOver(){ischanger = true;this.transform.position = new Vector3 (this.transform.position.x, 0.2f, this.transform.position.z);}//void OnMouseEnter(){//ischanger = true;//move_up = 1;//Debug.Log ("3333333");////}//鼠标不再上面引起的动作void OnMouseExit(){ischanger = false;this.transform.position = new Vector3 (this.transform.position.x, 0, this.transform.position.z);}/鼠标按下void OnMouseDown(){}//鼠标松开void OnMousePut(){}void Update () {// if (ischanger) {// Debug.Log ("33333");// this.transform.position = new Vector3 (this.transform.position.x, 0.2f, this.transform.position.z);//// } else {// this.transform.position = new Vector3 (this.transform.position.x, 0, this.transform.position.z);// }}}
阅读全文
0 0
- unity 鼠标悬停事件
- 鼠标悬停事件
- 笔记-鼠标悬停事件
- css 鼠标悬停事件
- hover鼠标悬停事件
- selenium 鼠标悬停事件
- 鼠标悬停,延后触发事件
- jQuery鼠标悬停事件.hover()用法说明
- echars 自定义触发鼠标悬停事件
- 用UGUI做一个鼠标悬停事件
- python中的selenium中的鼠标悬停事件!
- 重写鼠标悬停事件(针对IE)
- Unity鼠标事件
- unity 中的鼠标事件
- Unity鼠标双击事件
- 鼠标悬停
- 鼠标悬停
- Unity—NGUI—鼠标悬停播放 Sprite Animation
- HDOJ 2027 统计元音
- crontab
- 错误:Property of 'java.util.Set<?>' type cannot be injected by 'List'的解决方案
- Multiply Strings(大数相乘)
- Q107:Linux系统下GDB对PBRT-V3进行debug
- unity 鼠标悬停事件
- js创建型设计模式--简单工厂模式
- SmsManager发短信_随笔
- altium designer 13学习之添加泪滴
- RedHat、CentOS、Fedora 通过RPM安装MySQL 5.7.18版本 按照官网标准简易安装方法
- 使用指针连接字符串
- 面向对象思想设计原则
- 项目中分享功能的实现-----------一个小的记录
- Hibernate中的配置文件常用配置介绍