Version: 2022.3

Mesh.vertexBufferCount

切换到手册
public int vertexBufferCount ;

描述

获取网格中存在的顶点缓冲区数。(只读)

大多数网格只包含一个顶点缓冲区,但是某些网格(如某些平台上的蒙皮网格) 可能包含多个缓冲区。此属性最常与 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); } }