当前位置: 首页>>代码示例>>C#>>正文


C# Mesh.SetUVs方法代码示例

本文整理汇总了C#中UnityEngine.Mesh.SetUVs方法的典型用法代码示例。如果您正苦于以下问题:C# Mesh.SetUVs方法的具体用法?C# Mesh.SetUVs怎么用?C# Mesh.SetUVs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UnityEngine.Mesh的用法示例。


在下文中一共展示了Mesh.SetUVs方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: MakeStripped

        public static Mesh MakeStripped(List<Vector3> vertices, List<Vector3> normals = null, List<Vector2> uvs = null, List<Color32> colors = null, bool isBacksided = false)
        {
            Mesh mesh = new Mesh();
            mesh.SetVertices(vertices);
            if (normals != null)
            {
                mesh.SetNormals(normals);
            }
            if (uvs != null)
            {
                mesh.SetUVs(0, uvs);
            }
            if (colors != null)
            {
                mesh.SetColors(colors);
            }

            List<int> _tris = new List<int>();
            for (int i = 1; i < vertices.Count - 1; i += 2)
            {
                _tris.Add(i);
                _tris.Add(i - 1);
                _tris.Add(i + 1);

                if (isBacksided)
                {
                    _tris.Add(i + 1);
                    _tris.Add(i - 1);
                    _tris.Add(i);
                }

                if (i + 2 < vertices.Count)
                {
                    _tris.Add(i);
                    _tris.Add(i + 1);
                    _tris.Add(i + 2);

                    if (isBacksided)
                    {
                        _tris.Add(i + 2);
                        _tris.Add(i + 1);
                        _tris.Add(i);
                    }
                }
            }

            mesh.SetTriangles(_tris, 0);
            return mesh;
        }
开发者ID:JokieW,项目名称:ShiningHill,代码行数:49,代码来源:MeshUtils.cs

示例2: ToMesh

 /// <summary>
 /// Creates new mesh from information in draft
 /// </summary>
 public Mesh ToMesh()
 {
     var mesh = new Mesh {name = name};
     mesh.SetVertices(vertices);
     mesh.SetTriangles(triangles, 0);
     mesh.SetNormals(normals);
     mesh.SetUVs(0, uv);
     mesh.SetColors(colors);
     return mesh;
 }
开发者ID:emomper23,项目名称:PsychVR,代码行数:13,代码来源:MeshDraft.cs

示例3: BakeMesh

    private Mesh BakeMesh(InstanceData[] instances)
    {
        if (meshFilter == null)
        {
            meshFilter = GetComponent<MeshFilter>();
        }

        Mesh mesh = new Mesh();
        var meshVertices = meshFilter.sharedMesh.vertices;
        var meshUVs = meshFilter.sharedMesh.uv;
        var indices = meshFilter.sharedMesh.GetIndices(0);
        var normals = meshFilter.sharedMesh.normals;

        var vertexData = new List<Vector3>();
        var normalData = new List<Vector3>();
        var uv0Data = new List<Vector2>();

        for (int instanceIdx = 0; instanceIdx < instances.Length; instanceIdx++)
        {
            var scale = Vector3.Lerp(minScale, maxScale, UnityEngine.Random.value);
            var cur = instances[instanceIdx];

            var instancePos = new Vector3(Mathf.Cos(cur.startAngle), cur.verticalOffset, Mathf.Sin(cur.startAngle)) * cur.ringRadius;

            var instanceRotation = Quaternion.AngleAxis(UnityEngine.Random.value * 360, UnityEngine.Random.insideUnitSphere);

            vertexData.AddRange(meshVertices.Select(v => instancePos + instanceRotation * (new Vector3(v.x * scale.x, v.y * scale.y, v.z * scale.z) * meshScale)));
            normalData.AddRange(normals.Select(v => Vector3.Normalize(instanceRotation * new Vector3(v.x * scale.x, v.y * scale.y, v.z * scale.z) * meshScale)));
            uv0Data.AddRange(meshUVs);
        }

            mesh.SetVertices(vertexData);
        mesh.SetIndices(Enumerable.Range(0, instances.Length).SelectMany(i => indices.Select(vi => i * meshVertices.Length + vi)).ToArray(), MeshTopology.Triangles, 0);
        mesh.SetUVs(0, uv0Data);
            mesh.SetNormals(normalData);

        mesh.RecalculateNormals();
        mesh.RecalculateBounds();

        mesh.Optimize();

        return mesh;
    }
开发者ID:Ronmenator,项目名称:GalaxyExplorer,代码行数:43,代码来源:AsteroidRing.cs

示例4: FillMesh

        protected void FillMesh(Mesh mesh)
        {
            mesh.Clear();

            if (positions.Count > 65000)
                throw new System.ArgumentException("Mesh cannot have more than 65000 vertices.");	// Limitation based on UnityEngine.UI.VertexHelper

            mesh.SetVertices(positions);
            //mesh.SetColors(colors); // 5.3 mesh.SetColors(Color) is broken in UI.
            mesh.SetColors(colors32);
            mesh.SetUVs(0, uvs);
            mesh.SetNormals(normals);
            mesh.SetTriangles(indices, 0);

            mesh.RecalculateBounds();
        }
开发者ID:redguitar,项目名称:spine-runtimes,代码行数:16,代码来源:VertexHelperSpineMeshGenerator.cs

示例5: ProcessMesh

    static void ProcessMesh(Mesh mesh)
    {
        var ia_i = mesh.triangles;
        var vcount = ia_i.Length;

        // Split all the shared vertices.

        var va_o = new Vector3[vcount];
        var na_o = new Vector3[vcount];

        var va_i = mesh.vertices;
        var na_i = mesh.normals;

        for (var i = 0; i < vcount; i++)
        {
            var vi = ia_i[i];
            va_o[i] = va_i[vi];
            na_o[i] = na_i[vi];
        }

        mesh.vertices = va_o;
        mesh.normals = na_o;

        // UV0 - the centroid of the triangle
        // UV1 - the next vertex in the triangle
        // UV2 - the previous vertex in the triangle

        var uv0 = new List<Vector3>(vcount);
        var uv1 = new List<Vector3>(vcount);
        var uv2 = new List<Vector3>(vcount);

        for (var i = 0; i < vcount; i += 3)
        {
            var v0 = va_i[ia_i[i    ]];
            var v1 = va_i[ia_i[i + 1]];
            var v2 = va_i[ia_i[i + 2]];

            var center = (v0 + v1 + v2) / 3;

            uv0.Add(center);
            uv0.Add(center);
            uv0.Add(center);

            uv1.Add(v1);
            uv1.Add(v2);
            uv1.Add(v0);

            uv2.Add(v2);
            uv2.Add(v0);
            uv2.Add(v1);
        }

        mesh.SetUVs(0, uv0);
        mesh.SetUVs(1, uv1);
        mesh.SetUVs(2, uv2);

        // Rebuild all the triangles with the split vertices.

        var vi2 = 0;
        for (var smi = 0; smi < mesh.subMeshCount; smi++)
        {
            var sia_i = mesh.GetTriangles(smi);
            var sia_o = new int[sia_i.Length];
            for (var i = 0; i < sia_o.Length; i++) sia_o[i] = vi2++;
            mesh.SetTriangles(sia_o, smi);
        }
    }
开发者ID:esther5576,项目名称:SW-game-project,代码行数:67,代码来源:TextModelPostprocessor.cs

示例6: CutObject


//.........这里部分代码省略.........
                                            tmpIntersectionUv);

                // add intersection point into overall buffers
                tmpLowerHull.AddRange(tmpIntersectionPt);
                tmpUpperHull.AddRange(tmpIntersectionPt);
                tmpLowerHullUV.AddRange(tmpIntersectionUv);
                tmpUpperHullUV.AddRange(tmpIntersectionUv);

                closingHull.AddRange(tmpIntersectionPt);

                // triangulate the temporary buffers and get the indices
                Triangulator.TriangulateNDSlice(tmpLowerHull, tmpLowerIndices, lowerHull.Count);
                Triangulator.TriangulateNDSlice(tmpUpperHull, tmpUpperIndices, upperHull.Count);

                // add to the final buffers
                upperHull.AddRange(tmpUpperHull);
                lowerHull.AddRange(tmpLowerHull);
                upperIndices.AddRange(tmpUpperIndices);
                lowerIndices.AddRange(tmpLowerIndices);
                upperUV.AddRange(tmpUpperHullUV);
                lowerUV.AddRange(tmpLowerHullUV);
            }

            List<Vector3> finalClosingHull = new List<Vector3>();

            // generate the closing hull (if any)
            if (closingHull.Count > 0) {
                Triangulator.TriangulateHullPt(closingHull, finalClosingHull, closingHullIndices, closingHullUV, plane.Normal);
            }

            if (upperIndices.Count > 0) {
                Mesh newMesh = new Mesh();

                newMesh.subMeshCount = 2;

                // close the hull
                int count = upperHull.Count;
                upperHull.AddRange(finalClosingHull);
                upperUV.AddRange(closingHullUV);

                newMesh.SetVertices(upperHull);
                newMesh.SetTriangles(upperIndices, 0);
                newMesh.SetUVs(0, upperUV);

                // set the closing hull UV's
                int triCount = closingHullIndices.Count;

                if (triCount > 0) {
                    List<int> finalTriangles = new List<int>();

                    for (int i = 0; i < triCount; i += 3) {
                        finalTriangles.Add(closingHullIndices[i] + count);
                        finalTriangles.Add(closingHullIndices[i + 2] + count);
                        finalTriangles.Add(closingHullIndices[i + 1] + count);
                    }

                    newMesh.SetTriangles(finalTriangles, 1);
                }

                newMesh.RecalculateNormals();

                newMeshes.Add(newMesh);
            }

            if (lowerIndices.Count > 0) {
                Mesh newMesh = new Mesh();

                newMesh.subMeshCount = 2;

                // close the hull
                int count = lowerHull.Count;
                lowerHull.AddRange(finalClosingHull);
                lowerUV.AddRange(closingHullUV);

                newMesh.SetVertices(lowerHull);
                newMesh.SetTriangles(lowerIndices, 0);
                newMesh.SetUVs(0, lowerUV);

                // set the closing hull UV's
                int triCount = closingHullIndices.Count;

                if (triCount > 0) {
                    List<int> finalTriangles = new List<int>();

                    for (int i = 0; i < triCount; i += 3) {
                        finalTriangles.Add(closingHullIndices[i] + count);
                        finalTriangles.Add(closingHullIndices[i + 1] + count);
                        finalTriangles.Add(closingHullIndices[i + 2] + count);
                    }

                    newMesh.SetTriangles(finalTriangles, 1);
                }

                newMesh.RecalculateNormals();

                newMeshes.Add(newMesh);
            }

            return newMeshes;
        }
开发者ID:DavidArayan,项目名称:EzySlice,代码行数:101,代码来源:MeshSlicer.cs

示例7: BakeDownMesh

        // copy a mesh, and bake it's vertex stream into the mesh data.
        Mesh BakeDownMesh(Mesh mesh, VertexInstanceStream stream)
        {
            var copy = new Mesh();
             foreach(var property in typeof(Mesh).GetProperties())
             {
            if(property.GetSetMethod() != null && property.GetGetMethod() != null)
            {
               property.SetValue(copy, property.GetValue(mesh, null), null);
            }
             }
             copy.hideFlags = 0;

             copy.colors = stream.colors;
             if (stream.uv0 != null) { copy.SetUVs(0, stream.uv0); }
             if (stream.uv1 != null) { copy.SetUVs(1, stream.uv1); }
             if (stream.uv2 != null) { copy.SetUVs(2, stream.uv2); }
             if (stream.uv3 != null) { copy.SetUVs(3, stream.uv3); }

             if (stream.positions != null && stream.positions.Length == copy.vertexCount)
             {
            copy.vertices = stream.positions;
             }
             if (stream.normals != null && stream.normals.Length == copy.vertexCount)
             {
            copy.normals = stream.normals;
             }
             if (stream.tangents != null && stream.tangents.Length == copy.vertexCount)
             {
            copy.tangents = stream.tangents;
             }
             copy.Optimize();
             copy.RecalculateBounds();
             copy.UploadMeshData(false);

             return copy;
        }
开发者ID:CarlosMeloStuff,项目名称:VertexPaint,代码行数:37,代码来源:VertexPainterWindow_GUI.cs

示例8: Update


//.........这里部分代码省略.........

                // Ensure ordering
                if (Vector3.Dot(Vector3.Cross(verts[i1] - verts[i0], verts[i2] - verts[i0]), vert0) < 0f)
                {
                    int tmp = i1;
                    i1 = i3;
                    i3 = tmp;
                }

                edgeTris.AddRange(new int[] { i0, i1, i2, i0, i2, i3 });

                // Normal
                Vector3 normal = 0.5f * (vert0 + vert1);
                normal.Normalize();
                normals.AddRange(new Vector3[] { normal, normal, normal, normal });

                // The UVs encode the sampling plane normals.
                Vector2 uv0 = encodeNormalToUV(midPoint0.normalized);
                Vector2 uv1 = encodeNormalToUV(midPoint1.normalized);

                uvNormal0.AddRange(new Vector2[] { uv0, uv0, uv0, uv0 });
                uvNormal1.AddRange(new Vector2[] { uv1, uv1, uv1, uv1 });
                uvNormal2.AddRange(new Vector2[] { Vector2.zero, Vector2.zero, Vector2.zero, Vector2.zero });

                // Blend weights are stored in the color channel
                Color c0 = new Color(1f, 0f, 0f);
                Color c1 = new Color(0f, 1f, 0f);
                colors.AddRange(new Color[] { c0, c1, c1, c0 });
            }

            // Compute the bevelled vertices.
            // Those have three blend weights.
            List<int> vertTris = new List<int>(20 * 3);

            for (int i=0; i<20; i++)
            {
                Vector3 normal = rawVerts[i].normalized;

                // The UVs encode the sampling plane normals.
                Vector2 uv0 = encodeNormalToUV(faceMidPoints[vertFaceIndices[i, 0]].normalized);
                Vector2 uv1 = encodeNormalToUV(faceMidPoints[vertFaceIndices[i, 1]].normalized);
                Vector2 uv2 = encodeNormalToUV(faceMidPoints[vertFaceIndices[i, 2]].normalized);

                for (int j=0; j<3; j++)
                {
                    int faceIdx = vertFaceIndices[i, j];
                    Vector3 faceMidPoint = faceMidPoints[faceIdx];

                    Vector3 beveledVertexPosition = faceMidPoint + (1f - bevel) * (rawVerts[i] - faceMidPoint);
                    verts.Add(beveledVertexPosition);

                    normals.Add(normal);

                    uvNormal0.Add(uv0);
                    uvNormal1.Add(uv1);
                    uvNormal2.Add(uv2);
                }

                // Blend weights are stored in the color channel.
                colors.Add(new Color(1f, 0f, 0f));
                colors.Add(new Color(0f, 1f, 0f));
                colors.Add(new Color(0f, 0f, 1f));

                // Indices
                int i0 = verts.Count - 3;
                int i1 = verts.Count - 2;
                int i2 = verts.Count - 1;

                // Ensure ordering
                if (Vector3.Dot (Vector3.Cross(verts[i1] - verts[i0], verts[i2] - verts[i0]), rawVerts[i]) < 0)
                {
                    int tmp = i1;
                    i1 = i2;
                    i2 = tmp;
                }

                vertTris.AddRange(new int[] { i0, i1, i2 });
            }

            // Finish setting up the mesh.
            mesh.SetVertices(verts);
            mesh.SetNormals(normals);
            mesh.SetColors(colors);
            mesh.SetUVs(0, uvNormal0);
            mesh.SetUVs(1, uvNormal1);
            mesh.SetUVs(2, uvNormal2);

            // There are three sub-meshes: Face faces, edge faces, and vertex faces.
            mesh.subMeshCount = 3;

            mesh.SetTriangles(faceTris, 0);
            mesh.SetTriangles(edgeTris, 1);
            mesh.SetTriangles(vertTris, 2);

            // If there is a mesh filter component, apply the mesh.
            var meshFilter = GetComponent<MeshFilter>();
            if (meshFilter)
                meshFilter.sharedMesh = mesh;
        }
    }
开发者ID:huwb,项目名称:volsample,代码行数:101,代码来源:PlatonicSolidBlend.cs

示例9: FillMesh

 /// <summary>
 /// <para>Fill the given mesh with the stream data.</para>
 /// </summary>
 /// <param name="mesh"></param>
 public void FillMesh(Mesh mesh)
 {
     mesh.Clear();
     if (this.m_Positions.Count >= 0xfde8)
     {
         throw new ArgumentException("Mesh can not have more than 65000 vertices");
     }
     mesh.SetVertices(this.m_Positions);
     mesh.SetColors(this.m_Colors);
     mesh.SetUVs(0, this.m_Uv0S);
     mesh.SetUVs(1, this.m_Uv1S);
     mesh.SetNormals(this.m_Normals);
     mesh.SetTangents(this.m_Tangents);
     mesh.SetTriangles(this.m_Indices, 0);
     mesh.RecalculateBounds();
 }
开发者ID:CarlosHBC,项目名称:UnityDecompiled,代码行数:20,代码来源:VertexHelper.cs

示例10: SetVertices

 public void SetVertices(UIVertex[] vertices, int size)
 {
     Mesh mesh = new Mesh();
     List<Vector3> inVertices = new List<Vector3>();
     List<Color32> inColors = new List<Color32>();
     List<Vector2> uvs = new List<Vector2>();
     List<Vector2> list4 = new List<Vector2>();
     List<Vector3> inNormals = new List<Vector3>();
     List<Vector4> inTangents = new List<Vector4>();
     List<int> list7 = new List<int>();
     for (int i = 0; i < size; i += 4)
     {
         for (int j = 0; j < 4; j++)
         {
             inVertices.Add(vertices[i + j].position);
             inColors.Add(vertices[i + j].color);
             uvs.Add(vertices[i + j].uv0);
             list4.Add(vertices[i + j].uv1);
             inNormals.Add(vertices[i + j].normal);
             inTangents.Add(vertices[i + j].tangent);
         }
         list7.Add(i);
         list7.Add(i + 1);
         list7.Add(i + 2);
         list7.Add(i + 2);
         list7.Add(i + 3);
         list7.Add(i);
     }
     mesh.SetVertices(inVertices);
     mesh.SetColors(inColors);
     mesh.SetNormals(inNormals);
     mesh.SetTangents(inTangents);
     mesh.SetUVs(0, uvs);
     mesh.SetUVs(1, list4);
     mesh.SetIndices(list7.ToArray(), MeshTopology.Triangles, 0);
     this.SetMesh(mesh);
     UnityEngine.Object.DestroyImmediate(mesh);
 }
开发者ID:randomize,项目名称:VimConfig,代码行数:38,代码来源:CanvasRenderer.cs

示例11: Apply

		public void Apply(Mesh mesh)
		{
			if(mesh == null || mesh.vertexCount != Length)
			{
				Debug.LogError("Assigning texture blend weights with mismatched array length!");
				return;
			}

			for(int n = 0; n < channelMap.Length; n++)
			{
				int index = n * COMPONENTS_PER_ATTRIBUTE;

				switch(channelMap[n])
				{
					case z_MeshChannel.UV0:
						mesh.SetUVs(0, GetList(index));
						break;

					case z_MeshChannel.UV2:
						mesh.SetUVs(1, GetList(index));
						break;

					case z_MeshChannel.UV3:
						mesh.SetUVs(2, GetList(index));
						break;

					case z_MeshChannel.UV4:
						mesh.SetUVs(3, GetList(index));
						break;

					case z_MeshChannel.COLOR:
						mesh.colors32 = GetByteArray(index);
						break;
	
					case z_MeshChannel.TANGENT:
						mesh.tangents = GetArray(index);
						break;
				}
			}
		}
开发者ID:alex-carlson,项目名称:PixelitisGGJ,代码行数:40,代码来源:z_SplatSet.cs

示例12: GenerateFaceObject


//.........这里部分代码省略.........
                fUDel = 1.0f;
            float fVDel = (fVMax - fVMin);
            if (fVDel > cZeroTolerance)
                fVDel = 1.0f / fVDel;
            else
                fVDel = 1.0f;
            for (int n = 0; n < pVertexList.Length; n++)
            {
                (pVertexList)[n].lu = ((pVertexList)[n].lu - fUMin) * fUDel;
                (pVertexList)[n].lv = ((pVertexList)[n].lv - fVMin) * fVDel;
            }




            //    Debug.Log(lightMapWidth+" "+ lightMapHeight);
            Texture2D lightTex = new Texture2D(lightMapWidth, lightMapHeight);



            Color[] colourarray = new Color[lightMapWidth * lightMapHeight];

            int tempCount = (int)face.lightmapOffset;
            for (int k = 0; k < lightMapWidth * lightMapHeight; k++)
            {
                if (tempCount + 3 > map.lightlump.Length) break;
                colourarray[k] = new Color32(map.lightlump[tempCount], map.lightlump[tempCount + 1], map.lightlump[tempCount + 2], 100);
                tempCount += 3;
            }

            lightTex.SetPixels(colourarray);
           // lightTex.filterMode = FilterMode.Bilinear;
            lightTex.wrapMode = TextureWrapMode.Clamp;
            
            lightTex.Apply();

            Texture2D lmap = lightTex;




            List<Vector2> lvs = new List<Vector2>();
            for (int a=0; a< pVertexList.Length;a++)

            {

                lvs.Add(new Vector2(pVertexList[a].lu, pVertexList[a].lv));


            }
            faceMesh.SetUVs(1, lvs);
            // faceMesh.SetUVs(2, vlist);

            if (map.miptexLump [map.texinfoLump.texinfo [face.texinfo_id].miptex].texture == null)
						{
			
								bspMaterial.mainTexture = missingtexture;

						}
						else
						{
								bspMaterial.mainTexture = map.miptexLump [map.texinfoLump.texinfo [face.texinfo_id].miptex].texture;
								bspMaterial.mainTexture.name = map.miptexLump [map.texinfoLump.texinfo [face.texinfo_id].miptex].name;
						}
			
		


			
						bspMaterial.SetTexture ("_LightMap", lmap);
            bspMaterial.mainTexture.filterMode = FilterMode.Bilinear;
          
                        faceObject.GetComponent<Renderer>().material = bspMaterial;


				}
				else
				{
			
						if (map.miptexLump [map.texinfoLump.texinfo [face.texinfo_id].miptex].texture == null)
						{
								//faceObject.renderer.material.mainTexture = missingtexture;
								faceObject.GetComponent<Renderer>().material.mainTexture = missingtexture;
								Debug.LogError (map.miptexLump [map.texinfoLump.texinfo [face.texinfo_id].miptex].name.ToString () + "not loaded");
						}
						else
						{
								faceObject.GetComponent<Renderer>().material.mainTexture = map.miptexLump [map.texinfoLump.texinfo [face.texinfo_id].miptex].texture;
           

                faceObject.GetComponent<Renderer>().material.mainTexture.name = map.miptexLump [map.texinfoLump.texinfo [face.texinfo_id].miptex].name;
						}

				}
				faceObject.AddComponent<MeshCollider> ();
				faceObject.isStatic = true;
				//faceObject.renderer.enabled = false;

				return faceObject;
		}
开发者ID:Avatarchik,项目名称:unityHalf-life,代码行数:101,代码来源:GenerateMapVis.cs

示例13: generateMengerMesh

        private Mesh generateMengerMesh(int lod)
        {
            Mesh mesh = new Mesh();
              mesh.name = "MengerMesh";

              int size = Mathf.RoundToInt(Mathf.Pow(3, _subMeshLod));

              bool[,,] _isFilled = new bool[size, size, size];
              for (int x = 0; x < size; x++) {
            for (int y = 0; y < size; y++) {
              for (int z = 0; z < size; z++) {
            if (isSpaceFilled(x, y, z, size / 3)) {
              _isFilled[x, y, z] = true;
            }
              }
            }
              }

              List<Vector3> verts = new List<Vector3>();
              List<int> tris = new List<int>();

              float quadRadius = 0.5f / size;

              for (int x = 0; x < size; x++) {
            for (int y = 0; y < size; y++) {
              for (int z = 0; z < size; z++) {
            if (_isFilled[x, y, z]) {
              Vector3 position = new Vector3(x, y, z) / size + Vector3.one * quadRadius - Vector3.one * 0.5f;

              if (x == 0 || !_isFilled[x - 1, y, z]) {
                addQuad(verts, tris, position + Vector3.left * quadRadius, Vector3.forward, Vector3.up, quadRadius);
              }
              if (x == size - 1 || !_isFilled[x + 1, y, z]) {
                addQuad(verts, tris, position + Vector3.right * quadRadius, Vector3.up, Vector3.forward, quadRadius);
              }

              if (y == 0 || !_isFilled[x, y - 1, z]) {
                addQuad(verts, tris, position + Vector3.down * quadRadius, Vector3.right, Vector3.forward, quadRadius);
              }
              if (y == size - 1 || !_isFilled[x, y + 1, z]) {
                addQuad(verts, tris, position + Vector3.up * quadRadius, Vector3.forward, Vector3.right, quadRadius);
              }

              if (z == 0 || !_isFilled[x, y, z - 1]) {
                addQuad(verts, tris, position + Vector3.back * quadRadius, Vector3.up, Vector3.right, quadRadius);
              }
              if (z == size - 1 || !_isFilled[x, y, z + 1]) {
                addQuad(verts, tris, position + Vector3.forward * quadRadius, Vector3.right, Vector3.up, quadRadius);
              }
            }
              }
            }
              }

              List<Vector2> uvs = new List<Vector2>();
              for (int i = 0; i < verts.Count; i++) {
            uvs.Add(verts[i]);
              }

              mesh.SetVertices(verts);
              mesh.SetUVs(0, uvs);
              mesh.SetIndices(tris.ToArray(), MeshTopology.Triangles, 0);
              mesh.RecalculateNormals();
              mesh.RecalculateBounds();

              ;
              mesh.UploadMeshData(true);

              return mesh;
        }
开发者ID:SebiH,项目名称:BachelorProject,代码行数:70,代码来源:MengerSponge.cs

示例14: SetVertices

 public void SetVertices(UIVertex[] vertices, int size)
 {
   Mesh mesh = new Mesh();
   List<Vector3> inVertices = new List<Vector3>();
   List<Color32> inColors = new List<Color32>();
   List<Vector2> uvs1 = new List<Vector2>();
   List<Vector2> uvs2 = new List<Vector2>();
   List<Vector3> inNormals = new List<Vector3>();
   List<Vector4> inTangents = new List<Vector4>();
   List<int> intList = new List<int>();
   int num = 0;
   while (num < size)
   {
     for (int index = 0; index < 4; ++index)
     {
       inVertices.Add(vertices[num + index].position);
       inColors.Add(vertices[num + index].color);
       uvs1.Add(vertices[num + index].uv0);
       uvs2.Add(vertices[num + index].uv1);
       inNormals.Add(vertices[num + index].normal);
       inTangents.Add(vertices[num + index].tangent);
     }
     intList.Add(num);
     intList.Add(num + 1);
     intList.Add(num + 2);
     intList.Add(num + 2);
     intList.Add(num + 3);
     intList.Add(num);
     num += 4;
   }
   mesh.SetVertices(inVertices);
   mesh.SetColors(inColors);
   mesh.SetNormals(inNormals);
   mesh.SetTangents(inTangents);
   mesh.SetUVs(0, uvs1);
   mesh.SetUVs(1, uvs2);
   mesh.SetIndices(intList.ToArray(), MeshTopology.Triangles, 0);
   this.SetMesh(mesh);
   Object.DestroyImmediate((Object) mesh);
 }
开发者ID:BlakeTriana,项目名称:unity-decompiled,代码行数:40,代码来源:CanvasRenderer.cs

示例15: FillMesh

 public void FillMesh(Mesh mesh)
 {
     mesh.Clear();
     mesh.SetVertices(this.m_Positions);
     mesh.SetColors(this.m_Colors);
     mesh.SetUVs(0, this.m_Uv0S);
     mesh.SetUVs(1, this.m_Uv1S);
     mesh.SetNormals(this.m_Normals);
     mesh.SetTangents(this.m_Tangents);
     mesh.SetTriangles(this.m_Indicies, 0);
     mesh.RecalculateBounds();
 }
开发者ID:randomize,项目名称:VimConfig,代码行数:12,代码来源:VertexHelper.cs


注:本文中的UnityEngine.Mesh.SetUVs方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。