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

 时间:2024-10-15 14:19:06

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

工具/原料

Unity

MeshUV

一、知识要点

1、Mesh:Aclassthatallowscreat坡纠课柩ingormodifyingmeshesfrom惺绅寨瞀scripts.Meshescontainverticesandmultipletrianglearrays.SeetheProceduralexampleprojectforexamplesofusingthemeshinterface.Thetrianglearraysaresimplyindicesintothevertexarrays;threeindicesforeachtriangle.Foreveryvertextherecanbeanormal,twotexturecoordinates,colorandtangent.Theseareoptionalthoughandcanberemovedatwill.Allvertexinformationisstoredinseparatearraysofthesamesize,soifyourmeshhas10vertices,youwouldalsohave10-sizearraysfornormalsandotherattributes.

2、Mesh.uv:1)功能简介publicVector2[]掼鸿乡羰uv;ThebasetexturecoordinatesoftheM髫潋啜缅esh.2)笔记NoteTexturecoordinateshavetobemodifiedorcreatedexternallyfromtheMesh.Inthescriptexampleabove,theuvsiscreatedasanewarray,thenthetexturecoordinatesareassignedtothatarray.Oncetheseareassigned,thearrayisassignedtotheMesh.

二、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、到此,《UnityMesh教程之Mesh画的图形贴图UV处理》讲解结束,谢谢

幻塔榴火技能介绍 完美钢琴手机版如何更换皮肤 我的侠客酒馆仓库装备怎么用 转转app在哪里设置性别 摩尔庄园怎么买小鸡
热门搜索
怎么把图片变大 动漫美女福利 可爱头像动漫 树叶贴画作品图片大全 单色图片