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

图书馆门户网站建设有哪些公司西安市网站

图书馆门户网站建设有哪些公司,西安市网站,wordpress 注册设置密码,甘肃网站开发描述 点击鼠标左键在屏幕上绘制线段 准备 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.dnsts.com.cn/news/56326.html

相关文章:

  • 宜良网站建设手机网站 做成app
  • 潍坊网站建设建站手做网站
  • 广州网站推广多少钱百度蜘蛛开发网站
  • 用html能做企业网站吗seo托管
  • 上海做网站的公司wordpress 中国企业
  • 途谷网站建设企业风首页中文官网模板
  • 月嫂公司网站建设构思wordpress添加广告插件
  • 建设网站远达简单实用wordpress主题
  • 在阿里云做网站教程购物网站建设需求
  • 网站开发最新效果空间建网站
  • 网站开发类电脑网卡
  • iis 新建网站没有文件夹权限淘宝客怎么自己做网站
  • 网页制作作业网站网站建设论文html格式
  • 网站建设会议议程网站建设方案评审
  • 中牟网站推广山东建大建设有限公司网站
  • 丹徒网站建设公司公众号开发 网站开发
  • 有经验的永州网站建设5118站长网站
  • 西安做营销型网站建设网址的输入格式是什么样的
  • 找人做淘宝网站多少钱信息中心加强网站建设
  • 广东省建设安全监督站的网站自媒体策划哪里公司最好
  • 专业网站设计怎么做网站关键词没有排名
  • 如何建设手机端网站南京网站群建设公司
  • 公司要建设网站需要那些程序公司做一个静态网站多少钱
  • 医院网站建设需求分析河南23个岗位无人报考
  • 中太建设集团官方网站品牌公司
  • 青岛市建设工程质量安全监督站官方网站做网站前的准备什么
  • 嘉定网站公司网络工程师证书考试时间
  • 雅安建设机械网站学习做网站建设的学校
  • 林州企业网站建设wordpress微信公众平台插件
  • 如何做贴吧类网站多钱网站后台上次图片