返回网格具有的顶点属性数量。(只读)
此属性返回活动顶点属性的数量(请参阅 VertexAttributeDescriptor)。结合 GetVertexAttribute,它可以用于查询网格中存在的顶点属性信息,而无需任何托管分配。
using UnityEngine; using UnityEngine.Rendering;
public class ExampleScript : MonoBehaviour { void Start() { // Create a Mesh with custom vertex data layout var mesh = new Mesh(); mesh.SetVertexBufferParams(10, new VertexAttributeDescriptor(VertexAttribute.Position, VertexAttributeFormat.Float32, 3), new VertexAttributeDescriptor(VertexAttribute.Normal, VertexAttributeFormat.Float32, 3), new VertexAttributeDescriptor(VertexAttribute.Color, VertexAttributeFormat.UNorm8, 4));
// Prints 3 (three attributes) Debug.Log($"Vertex stream count: {mesh.vertexAttributeCount}");
// Cleanup Object.DestroyImmediate(mesh); } }