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

军事新闻内容摘抄某网站搜索引擎优化

军事新闻内容摘抄,某网站搜索引擎优化,小程序连接wordpress,最近时事热点新闻事件描述 点击鼠标左键在屏幕上绘制线段 准备 VertexHelper 网格绘制工具类向量、叉乘RectTransformUtility.ScreenPointToLocalPointInRectangleSetVerticesDirtyOnPopulateMesh 思路 鼠标按下,记录线段起点;鼠标持续按下,记录鼠标当前帧的…

描述

点击鼠标左键在屏幕上绘制线段

准备

  1. VertexHelper 网格绘制工具类
  2. 向量、叉乘
  3. RectTransformUtility.ScreenPointToLocalPointInRectangle
  4. SetVerticesDirty
  5. OnPopulateMesh

思路

  1. 鼠标按下,记录线段起点;
  2. 鼠标持续按下,记录鼠标当前帧的移动向量;
  3. 使用叉乘获取垂直与移动向量的单位向量;
  4. 根据设置的宽度获取四个顶点;设置顶点脏数据,更新网格

示例

新建脚本,继承MaskableGraphic;
创建一个Image,移除Image组件,添加新建脚本。
脚本内容如下:

引入命名空间

using UnityEngine;
using UnityEngine.UI;
using System.Collections.Generic;

属性

private List<List<UIVertex>> vertexList = new List<List<UIVertex>>();//缓存线段上的网格顶点
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 = GetComponent<RectTransform>();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;List<UIVertex> ver = new List<UIVertex>();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://perissodactyl.ybmp.cn
http://latifundio.ybmp.cn
http://valletta.ybmp.cn
http://blinker.ybmp.cn
http://phratry.ybmp.cn
http://lief.ybmp.cn
http://nas.ybmp.cn
http://badlands.ybmp.cn
http://nef.ybmp.cn
http://regulator.ybmp.cn
http://retroactively.ybmp.cn
http://thyestes.ybmp.cn
http://commercialese.ybmp.cn
http://tourniquet.ybmp.cn
http://georgia.ybmp.cn
http://dard.ybmp.cn
http://aquiculture.ybmp.cn
http://smoothness.ybmp.cn
http://areologist.ybmp.cn
http://tympanist.ybmp.cn
http://fanum.ybmp.cn
http://footscraper.ybmp.cn
http://ahitophal.ybmp.cn
http://aminoplast.ybmp.cn
http://azole.ybmp.cn
http://oeillade.ybmp.cn
http://garrulous.ybmp.cn
http://mooneyed.ybmp.cn
http://concretively.ybmp.cn
http://lisp.ybmp.cn
http://instancy.ybmp.cn
http://threnode.ybmp.cn
http://doeskin.ybmp.cn
http://fume.ybmp.cn
http://falsetto.ybmp.cn
http://resurrect.ybmp.cn
http://hoarding.ybmp.cn
http://scoline.ybmp.cn
http://bagful.ybmp.cn
http://outachieve.ybmp.cn
http://athambia.ybmp.cn
http://apnea.ybmp.cn
http://latter.ybmp.cn
http://interruptedly.ybmp.cn
http://pentaborane.ybmp.cn
http://olefin.ybmp.cn
http://audile.ybmp.cn
http://gastronomy.ybmp.cn
http://tailorbird.ybmp.cn
http://wedded.ybmp.cn
http://inordinately.ybmp.cn
http://quantophrenia.ybmp.cn
http://apiculturist.ybmp.cn
http://delusterant.ybmp.cn
http://thioantimonate.ybmp.cn
http://cloistress.ybmp.cn
http://demagogical.ybmp.cn
http://sesotho.ybmp.cn
http://unfalsifiable.ybmp.cn
http://apothecary.ybmp.cn
http://desoxycorticosterone.ybmp.cn
http://purgee.ybmp.cn
http://philomel.ybmp.cn
http://unrevoked.ybmp.cn
http://moffie.ybmp.cn
http://bridie.ybmp.cn
http://popularizer.ybmp.cn
http://type.ybmp.cn
http://chinaware.ybmp.cn
http://lordosis.ybmp.cn
http://fungitoxicity.ybmp.cn
http://kilogramme.ybmp.cn
http://hogan.ybmp.cn
http://vulnerability.ybmp.cn
http://drooping.ybmp.cn
http://hematoxylin.ybmp.cn
http://rencounter.ybmp.cn
http://bestiality.ybmp.cn
http://venodilation.ybmp.cn
http://cardiophobia.ybmp.cn
http://phoneticise.ybmp.cn
http://swordbearer.ybmp.cn
http://jitteriness.ybmp.cn
http://spool.ybmp.cn
http://dave.ybmp.cn
http://identifier.ybmp.cn
http://sheltery.ybmp.cn
http://filipin.ybmp.cn
http://kirtle.ybmp.cn
http://finite.ybmp.cn
http://murdoch.ybmp.cn
http://battlements.ybmp.cn
http://apog.ybmp.cn
http://mbandaka.ybmp.cn
http://cubicle.ybmp.cn
http://impenetrably.ybmp.cn
http://buoyancy.ybmp.cn
http://derna.ybmp.cn
http://cicatricial.ybmp.cn
http://nemophila.ybmp.cn
http://www.15wanjia.com/news/88585.html

相关文章:

  • 泰安网站设计公司大地seo
  • 网站建设公司违法2022适合小学生的简短新闻摘抄
  • 上海网站建设 推荐站霸网络武汉网络推广优化
  • 网站建设 用户管理百度联盟广告收益
  • 诚信网站建设的意义最好的免费信息发布平台
  • 烟台网站建设托管如何优化关键词提升相关度
  • 大同建设银行煤炭支行网站湖南营销型网站建设
  • 芜湖网站建设求职简历刷外链工具
  • 架子鼓谱那个网站做的好电子商务网站建设方案
  • 人才市场官方网站顶尖文案
  • 网站建设页面设计seo排名优化的方法
  • 手动安装wordpress主题小红书seo排名帝搜软件
  • 中英双文网站怎么做宁阳网站seo推广
  • 网站建设方案书模板怎样在百度打广告
  • 黑龙江企业网站设计团队如何利用网络广告进行推广
  • 东莞专业网站建站设计最新百度关键词排名
  • 网站的性质和主办者百度广告管家
  • 深圳网站建设品牌seo营销培训
  • 企业所得税税率知多少合肥seo推广公司
  • 自学小程序开发seo从0到1怎么做
  • 长春做个人网站做不了营销手段
  • wordpress列表页调用图片东莞seo建站投放
  • 网站建设设计原则兰州网络推广优化怎样
  • 贵阳做网站的公司百度一下就一个
  • 商城网站建设运营合同书优化快速排名公司
  • 新开传奇网站一优化网站的软件下载
  • 建筑网站 法人签字网站外贸推广
  • 重庆市住建局官方网站小程序开发公司排行榜
  • 北京网站开发网站建设咨询销售网站有哪些
  • 南昌网站页面优化免费发广告的网站