版本:Unity 6 (6000.0)
语言英语
  • C#

BatchCullingContext.ViewID

提出更改建议

成功!

感谢您帮助我们提高 Unity 文档的质量。尽管我们无法接受所有提交,但我们会阅读用户提出的每条更新建议,并在必要时进行更新。

关闭

提交失败

由于某种原因,无法提交您的更正建议。请在几分钟后重试。感谢您抽出时间帮助我们提高 Unity 文档的质量。

关闭

取消

描述

发起剔除的对象 ID。用法示例:为每个对象存储与剔除相关的数据。

// Example of per-view data, indexed by view ID

using System; using UnityEngine;

public class CullingExample : MonoBehaviour { private BatchRendererGroup batchRendererGroup; private Dictionary<BatchPackedCullingViewID, MyViewData> myPerViewData = new Dictionary<BatchPackedCullingViewID, MyViewData>();

void Start() { batchRendererGroup = new BatchRendererGroup(this.OnPerformCulling, IntPtr.Zero); }

public JobHandle OnPerformCulling( BatchRendererGroup rendererGroup, BatchCullingContext cullingContext, BatchCullingOutput cullingOutput, IntPtr userContext) { if (!myPerViewData.ContainsKey(cullingContext.viewID)) { // If the data doesn't exist for the current view, create it. myPerViewData[cullingContext.viewID] = new MyViewData(); } MyViewData currentViewData = myPerViewData[cullingContext.viewID];

// Do stuff with the current view's data.

/* You can also get the instance ID of the current view's gameObject (for example, Camera, Light, etc.) as follows: */ int instanceID = cullingContext.viewID.GetInstanceID();

/* The slice index depends on the view type. For example, for Cameras, the slice index is always zero. For cascaded shadow maps, it equals the index of the cascade. */ int sliceIndex = cullingContext.viewID.GetSliceIndex(); } }