Version: 2023.2

Mesh.GetBlendShapeBufferRange

切换到手册
public BlendShapeBufferRange GetBlendShapeBufferRange (int blendShapeIndex);

参数

blendShapeIndex Which blend shape to locate the data for.

返回

BlendShapeBufferRange A struct that describes the start and end index of the data for the given blend shape.

描述

Get the location of blend shape vertex data for a given blend shape.

When you call Mesh.GetBlendShapeBuffer with BlendShapeBufferLayout.PerShape, Unity returns a GraphicsBuffer that contains blend shape vertex data, ordered by blend shape.

When you call this function, Unity returns a BlendShapeBufferRange for the given blend shape. Use it to locate the data for that blend shape in the GraphicsBuffer.

using UnityEngine;
using UnityEngine.Rendering;

public class Example : MonoBehaviour { public Mesh mesh; public ComputeShader computeShader;

void Start() { // Fetch GraphicsBuffer with Blend Shape data, ordered per shape, from the mesh var perShapeBuffer = mesh.GetBlendShapeBuffer(BlendShapeBufferLayout.PerShape);

// Iterate over all Blend Shapes in a mesh for(int blendShapeIndex = 0; blendShapeIndex < mesh.blendShapeCount; ++blendShapeIndex) { // Fetch which indices in the buffer that are part of this Blend Shape var blendShapeRange = mesh.GetBlendShapeBufferRange(blendShapeIndex);

// Set the start and end indices of the Blend Shape in the compute shader computeShader.SetInt("_StartIndex", (int)blendShapeRange.startIndex); computeShader.SetInt("_EndIndex", (int)blendShapeRange.endIndex);

// Dispatch compute shader and access data between start and end index for this Blend Shape computeShader.Dispatch(0, 64, 1, 1); }

// Dispose of GraphicsBuffer to avoid leak memory perShapeBuffer.Dispose(); } }

See Also: UnityEngine.BlendShapeBufferRange, Mesh.GetBlendShapeBuffer, BlendShapeBufferLayout.PerShape

Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961