Unity Mesh教程 之 Mesh画的图形贴图UV处理

 时间:2024-10-12 21:06:02

Unity Mesh教程 之 Mesh画的图形贴图UV处理。在使用Mesh画兔脒巛钒图形时,如果UV不作处理,当贴上贴图时,贴图会不对。本节介绍在Mesh画图时的UV处理的简单案例,具体如下

工具/原料

Unity

Mesh UV

一、知识要点

1、Mesh:A class that allows creat坡纠课柩ing or modifying meshes from scripts.Meshes contain vertices and multiple triangle arrays. See theProcedural example projectfor examples of using the mesh interface.The triangle arrays are simply indices into the vertex arrays; three indices for each triangle.For every vertex there can be a normal, two texture coordinates, color and tangent. These are optional though and can be removed at will. All vertex information is stored in separate arrays of the same size, so if your mesh has 10 vertices, you would also have 10-size arrays for normals and other attributes.

2、Mesh.uv:1)功能简介public Vector2[]uv;The base texture coordinates of the M髫潋啜缅esh.2)笔记NoteTexture coordinates have to be modified or created externally from the Mesh. In the script example above, the uvs is created as a new array, then the texture coordinates are assigned to that array. Once these are assigned, the array is assigned to theMesh.

二、Mesh教程 之 Mesh画的图形贴图UV处理

1、打开Unity,新建一个空工程,具体如下

Unity Mesh教程 之 Mesh画的图形贴图UV处理

2、根据绘制三角形的方法,绘制一个图形,其中三角形点的赋值过程、代码和画图结果,具体如下图

Unity Mesh教程 之 Mesh画的图形贴图UV处理
Unity Mesh教程 之 Mesh画的图形贴图UV处理
Unity Mesh教程 之 Mesh画的图形贴图UV处理

3、在场景中,新建一个“Quad”,把绘制的附上一样的材质,结果大概一样,具体如下图

Unity Mesh教程 之 Mesh画的图形贴图UV处理

4、但是当给他们附上同样的Image的时候 ,右边绘制的就与原本的“Quad”有不同了,具体如下图

Unity Mesh教程 之 Mesh画的图形贴图UV处理

5、回到脚本中添加图形的UV,即把几个列表的点顺序加上去,代码和代码说明如下图

Unity Mesh教程 之 Mesh画的图形贴图UV处理

6、脚本编译正确后,回到Unity界面,运行场景,再把图片拖给他们,结果与原本一样的,具体如下图

Unity Mesh教程 之 Mesh画的图形贴图UV处理

7、到此,《Unity Mesh教程 之 Mesh画的图形贴图UV处理》讲解结束,谢谢

  • 幻塔榴火技能介绍
  • 完美钢琴手机版如何更换皮肤
  • 我的侠客酒馆仓库装备怎么用
  • 转转app在哪里设置性别
  • 摩尔庄园怎么买小鸡
  • 热门搜索
    运动会手抄报资料 手抄报的边框 爱眼手抄报 保护生态环境手抄报 创卫手抄报内容 海洋手抄报 廉洁教育手抄报 读书节手抄报图片 我爱足球手抄报 普通话规范字手抄报