Use of Unity mesh (GRID)

Source: Internet
Author: User

Create a rectangular grid of two triangular compositions:

Gameobject obj=NewGameobject (); Meshrenderer Meshrenderer=obj. Addcomponent<meshrenderer>(); Meshfilter Meshfilter=obj. Addcomponent<meshfilter>();//Render MaterialMeshrenderer.material=NewMaterial (Shader.find ("Sprites/default"));//create a material from a bagMeshrenderer.material.maintexture= (Texture) resources.load ("a");//"A" 2d texture under the Resources folderMesh Mesh=NewMesh (); Meshfilter.mesh=mesh;mesh.vertices=Newvector3[]{NewVector3 (0,0),NewVector3 (3,0),NewVector3 (0,3),NewVector3 (3,3)};//Mesh vertices//UV mapping coordinates, length and vertex number leader degree consistent, value 0~1mesh.uv=Newvector2[]{NewVector2 (0,0),NewVector2 (1,0),NewVector2 (0,1),NewVector2 (1,1) };//the vertex rendering order of the triangles, each of which corresponds to each vertex in the vertex array, the length is: the number of triangles, when a triangle is less filled, the triangle is not rendered, the length must be a multiple of 3mesh.triangles=New int[]{    0,1,2,    1,2,3};

Use of Unity mesh (GRID)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.