예제 #1
0
파일: Rectangle.cs 프로젝트: xenosl/ShuHai
        private void RebuildMesh()
        {
            if (Size.sqrMagnitude < Primitives.DefaultFloatTolerance)
            {
                return;
            }

            if (!_mesh)
            {
                _mesh = new Mesh();
            }

            var meshData = GeometryBuilder.BuildRectangle(Size, Plane);

            _mesh.vertices  = meshData.vertices.Select(v => v.Position).ToArray();
            _mesh.uv        = meshData.vertices.Select(v => v.Texcoord).ToArray();
            _mesh.triangles = meshData.triangles.SelectMany(t => t.ToArray()).ToArray();
            _mesh.RecalculateNormals();

            MeshFilter.sharedMesh = _mesh;
        }