- 最后登录
- 2021-7-6
- 注册时间
- 2012-12-27
- 阅读权限
- 90
- 积分
- 76145
- 纳金币
- 53488
- 精华
- 316
|
点击鼠标移动角色时,判断鼠标是否在NGUI的UI上,是就放弃移动- void Update()//检测鼠标.
- {
- if (Input.GetMouseButtonDown(0) )
- {
- if(MouseIsOnUI()==false)//不在UI上
- {
- //这里才响应移动
- }
- }
- }
- /// <summary>
- /// 鼠标是否在UI上.
- /// </summary>
- /// <returns><c>true</c>, if is on U was moused, <c>false</c> otherwise.</returns>
- bool MouseIsOnUI()
- {
- if(UICamera.hoveredObject ==null )
- {
- return false;
- }
- else if(UICamera.hoveredObject != null)
- {
- if(UICamera.hoveredObject.name=="UI Root" )
- {
- return false;
- }
- else
- {
- return true;
- }
- }
- return false;
- }
复制代码 |
|