Параметры
attr | Атрибут данных вершины для проверки. |
Возвращает
int Индекс потока атрибута данных или -1, если он отсутствует.
Описание
Получает индекс потока буфера вершин определенного атрибута данных вершины в этой сетке.
Сети обычно используют один поток буфера вершин, но можно настроить компоновку вершин, в которой атрибуты используют разные буферы вершин (см. SetVertexBufferParams). При использовании такого макета используйте эту функцию, чтобы запросить, частью какого потока буфера вершин является данный атрибут.
Обратите внимание, что эта функция возвращает индекс потока, не указывая, где находится атрибут в потоке. Чтобы определить местоположение данного атрибута в потоке, используйте GetVertexAttributeOffset.
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 stream indices: 0, 0, 1
Debug.Log($"Position stream {mesh.GetVertexAttributeStream(VertexAttribute.Position)}");
Debug.Log($"Normal stream {mesh.GetVertexAttributeStream(VertexAttribute.Normal)}");
Debug.Log($"Color stream {mesh.GetVertexAttributeStream(VertexAttribute.Color)}");
// Cleanup
Object.DestroyImmediate(mesh);
}
}
Смотрите так же: VertexAttribute, HasVertexAttribute, GetVertexAttributeOffset, vertexBufferCount, GetVertexBufferStride.