Version: 2021.1
言語: 日本語
public void SetNextIndex (ushort index);

パラメーター

index The value of the next index.

説明

Assigns the value of the next index of the allocated indices list.

Used to iteratively fill the values of the allocated indices via repeated calls to this function until all values have been provided. This way of filling index data is mutually exclusive with the use of SetAllIndices. After each invocation to this function, the internal counter for the next index is automatically incremented. When this method is called, it is not possible to use SetAllIndices to fill the indices. The index values provided refer directly to the vertices allocated in the same MeshWriteData object. Thus, an index of 0 means the first vertex and index 1 means the second vertex and so on.

using UnityEngine.UIElements;
public class MyVisualElement : VisualElement
{
    void MyGenerateVisualContent(MeshGenerationContext mgc)
    {
        var meshWriteData = mgc.Allocate(4, 6);
        // meshWriteData has been allocated with 6 indices for 2 triangles

// ... set the vertices

// Set indices for the first triangle meshWriteData.SetNextIndex(0); meshWriteData.SetNextIndex(1); meshWriteData.SetNextIndex(2);

// Set indices for the second triangle meshWriteData.SetNextIndex(2); meshWriteData.SetNextIndex(1); meshWriteData.SetNextIndex(3); } }

Note that calling SetNextIndex fewer times than the allocated number of indices will leave the remaining indices with random values as MeshGenerationContext.Allocate does not initialize the returned data to 0 to avoid redundant work.

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