当前位置: 首页 > news >正文

如何制造一个网站域名分类网站

如何制造一个网站,域名分类网站,阿里云搭建网站教程,哪些网站做平面单页好看描述 点击鼠标左键在屏幕上绘制线段 准备 VertexHelper 网格绘制工具类向量、叉乘RectTransformUtility.ScreenPointToLocalPointInRectangleSetVerticesDirtyOnPopulateMesh 思路 鼠标按下#xff0c;记录线段起点#xff1b;鼠标持续按下#xff0c;记录鼠标当前帧的…描述 点击鼠标左键在屏幕上绘制线段 准备 VertexHelper 网格绘制工具类向量、叉乘RectTransformUtility.ScreenPointToLocalPointInRectangleSetVerticesDirtyOnPopulateMesh 思路 鼠标按下记录线段起点鼠标持续按下记录鼠标当前帧的移动向量使用叉乘获取垂直与移动向量的单位向量根据设置的宽度获取四个顶点设置顶点脏数据,更新网格 示例 新建脚本继承MaskableGraphic 创建一个Image,移除Image组件添加新建脚本。 脚本内容如下 引入命名空间 using UnityEngine; using UnityEngine.UI; using System.Collections.Generic;属性 private ListListUIVertex vertexList new ListListUIVertex();//缓存线段上的网格顶点 private Vector3 lastPoint;//上一帧的点击点 private Vector3 lastLeftPoint; private Vector3 lastRightPoint; bool isNewLine;//绘制新的线段 [SerializeField] private float lineWidth 4f;//线段宽度方法 绘制网格 protected override void OnPopulateMesh(VertexHelper vh)//绘制网格 {vh.Clear();for (int i 0; i vertexList.Count; i)vh.AddUIVertexQuad(vertexList[i].ToArray()); }方法 屏幕坐标转为本地坐标 Vector2 ScreenPointToLocalPoint(Vector2 mousePoint) {var Rect GetComponentRectTransform();Vector2 result Vector2.zero;switch (canvas.renderMode){case RenderMode.ScreenSpaceOverlay:RectTransformUtility.ScreenPointToLocalPointInRectangle(Rect, mousePoint, null, out result);break;case RenderMode.ScreenSpaceCamera:RectTransformUtility.ScreenPointToLocalPointInRectangle(Rect, mousePoint, canvas.worldCamera, out result);break;case RenderMode.WorldSpace:RectTransformUtility.ScreenPointToLocalPointInRectangle(Rect, mousePoint, canvas.worldCamera, out result);break;}return result; }方法 设置网格顶点 private void Update() {if (Input.GetMouseButtonDown(0))//按下鼠标坐标表示 绘制新的线段{lastPoint ScreenPointToLocalPoint(Input.mousePosition);//屏幕点转换到当前recttransform上的点isNewLine true;vertexList.Clear();//清除上一次绘制的线段 若要保留 可不清除}else{if (Input.GetMouseButton(0)){Vector3 currentPoint ScreenPointToLocalPoint(Input.mousePosition);Vector3 dir currentPoint - lastPoint;//移动向量if (dir.magnitude 10)//移动量过小 不绘制网格return;Vector3 normal Vector3.Cross(dir.normalized, transform.forward);//移动向量和当前ui的朝向 进行叉乘if (isNewLine){isNewLine false;lastLeftPoint lastPoint normal * lineWidth;//绘制新的线段时 作为左侧起点lastRightPoint lastPoint - normal * lineWidth;}Vector3 leftPoint currentPoint normal * lineWidth;//当前线段的左侧终点Vector3 rightPoint currentPoint - normal * lineWidth;ListUIVertex ver new ListUIVertex();UIVertex uIVertex new UIVertex();//网格顶点列表uIVertex.position lastLeftPoint;uIVertex.color color;ver.Add(uIVertex);UIVertex uIVertex2 new UIVertex();uIVertex2.position lastRightPoint;uIVertex2.color color;ver.Add(uIVertex2);UIVertex uIVertex3 new UIVertex();uIVertex3.position rightPoint;uIVertex3.color color;ver.Add(uIVertex3);UIVertex uIVertex4 new UIVertex();uIVertex4.position leftPoint;uIVertex4.color color;ver.Add(uIVertex4);vertexList.Add(ver);lastLeftPoint leftPoint;//更新起点 当前帧的终点作为下一帧的起点lastRightPoint rightPoint;lastPoint currentPoint;SetVerticesDirty();//设置顶点脏数据 更新网格}} }
http://www.w-s-a.com/news/440160/

相关文章:

  • 解析视频的网站怎么做凡科网快图
  • 企业网站优化问题接单app平台有哪些
  • 怎么做网站后缀识别符号才不会变什么是电子商务网站建设
  • 中山 五金 骏域网站建设专家专门用来制作网页的软件是什么
  • 怎么做刷东西的网站数据分析软件工具有哪些
  • 官方购物网站正品交易网站域名
  • lol网站建设seo 网站太小
  • 网站建设销售职责手机网站制作软件
  • 福州百度企业网站seo如何在电脑上登录wordpress
  • 开发区全力做好网站建设网络广告营销成功案例
  • 114网站建设高并发系统架构
  • php网站打开一片空白wordpress中文广告插件下载
  • 怎样建自己的网站免费的百度关键词排名点击
  • 医院网站建设的特点怎么查看网站百度快照
  • 网站 如何备案一般网站开发公司
  • 做网站的公司 贵阳郑州新像素ui设计培训收费
  • 温州网站建设公司电话给个免费的网址
  • 个人做电子商务网站备案软考高级
  • 淘宝客需要自己做网站吗四川遂宁做网站的公司
  • 编写网站策划书缘魁上海网站建设
  • 梧州外贸网站推广设计wordpress 上传 七牛
  • 增加网站备案千灯做网站
  • 深圳做网站的公php做简易网站
  • 徐州哪家做网站好商业空间设计效果图
  • 重庆建网站cqiezscom大学毕业做网站插画师好吗
  • 在门户网站做产品seo怎么样做网站管理员
  • 动画做视频在线观看网站字体安装+wordpress
  • vs2015网站开发做珠宝建个网站推广怎么样
  • 大桥外语官方网站星做宝贝佛山微信网站开发
  • 河南建设网站公司哪家好怎样做一家网站