用NGUI显示图片鼠标点击的地方出现在屏幕上
2015-09-12 20:14
627 查看
void CreateCircle()
{
float offsetX, offsetY;
offsetX = Input.mousePosition.x;
offsetY = Input.mousePosition.y;
Vector3 pos = Camera.main.WorldToScreenPoint(worldPos);
pos.z = 0f;
Vector3 pointPos = new Vector3(pos.x + offsetX, pos.y + offsetY, 0);
Vector3 pos2 = UICamera.currentCamera.ScreenToWorldPoint(pointPos);
GameObject pointGo = NGUITools.AddChild(go, pointPre);
pointGo.transform.position = pos2;
}
if(Input.GetMouseButtonDown(0))
{
//if (UICamera.hoveredObject != null)
//{
// print("点到NGUI");
//}else
//{
// print("touch1!!!!!!!!!!!!!!!!!");
// //if (ControlSelf._instance.isexisted) return;
// if (CheckPointExist()) return;
// CreateCircle();
//}
Ray ray = UICamera.mainCamera.ScreenPointToRay(Input.mousePosition);// 向屏幕发射线
RaycastHit hit;
if (Physics.Raycast(ray, out hit, 200))//射线的碰撞检测
{
print("点到NGUI");
}
else
{
print("touch1!!!!!!!!!!!!!!!!!");
//if (ControlSelf._instance.isexisted) return;
if (CheckPointExist()) return;
CreateCircle();
}
{
float offsetX, offsetY;
offsetX = Input.mousePosition.x;
offsetY = Input.mousePosition.y;
Vector3 pos = Camera.main.WorldToScreenPoint(worldPos);
pos.z = 0f;
Vector3 pointPos = new Vector3(pos.x + offsetX, pos.y + offsetY, 0);
Vector3 pos2 = UICamera.currentCamera.ScreenToWorldPoint(pointPos);
GameObject pointGo = NGUITools.AddChild(go, pointPre);
pointGo.transform.position = pos2;
}
if(Input.GetMouseButtonDown(0))
{
//if (UICamera.hoveredObject != null)
//{
// print("点到NGUI");
//}else
//{
// print("touch1!!!!!!!!!!!!!!!!!");
// //if (ControlSelf._instance.isexisted) return;
// if (CheckPointExist()) return;
// CreateCircle();
//}
Ray ray = UICamera.mainCamera.ScreenPointToRay(Input.mousePosition);// 向屏幕发射线
RaycastHit hit;
if (Physics.Raycast(ray, out hit, 200))//射线的碰撞检测
{
print("点到NGUI");
}
else
{
print("touch1!!!!!!!!!!!!!!!!!");
//if (ControlSelf._instance.isexisted) return;
if (CheckPointExist()) return;
CreateCircle();
}
相关文章推荐
- 给NGUI上的预设体动态添加点击事件
- NUI四种提交数据方式
- NUI四种提交数据方式
- 触控手势怎么设计才好用(一)
- 触控手势怎么设计才好用(一)
- nui 的 form表单提交(兼容ajax和表单submit)
- nui字典组件使用
- Java请求参数类QueryParameter
- EasyUI学习笔记_1
- 关于UI线程的阻塞问题以及处理方式
- Dynamic Programming实战一:Longest Increasing Subsequence算法分析及C代码实现
- POJ 1776 - Task Sequences(哈密顿图)
- UIStatusBarStyle的类型改变
- UISegmentedControl 开发笔记
- Android Dialog中的Builder设计模式
- POJ - 1986 Distance Queries(LCA离线)
- Codeforces Round #316 Tree Requests
- easyui的datagrid为何无法显示json数据
- UI 自定义视图
- iOS开发-------简单通讯录2(UISearchController)