获取网格中存在的顶点缓冲区的数量。(只读)
大多数网格仅包含一个顶点缓冲区,但某些网格(例如某些平台上的蒙皮网格)可能包含多个顶点缓冲区。该属性与 GetNativeVertexBufferPtr 搭配使用时非常有用,以便从 原生代码插件 启用网格操作。
using UnityEngine; using UnityEngine.Rendering;
public class ExampleScript : MonoBehaviour { void Start() { // Create a Mesh with custom vertex data layout: // position and normal go into stream 0, // color goes into stream 1. var mesh = new Mesh(); mesh.SetVertexBufferParams(10, new VertexAttributeDescriptor(VertexAttribute.Position, VertexAttributeFormat.Float32, 3, stream:0), new VertexAttributeDescriptor(VertexAttribute.Normal, VertexAttributeFormat.Float32, 3, stream:0), new VertexAttributeDescriptor(VertexAttribute.Color, VertexAttributeFormat.UNorm8, 4, stream:1));
// Prints 2 (two vertex streams) Debug.Log($"Vertex stream count: {mesh.vertexBufferCount}");
// Cleanup Object.DestroyImmediate(mesh); } }