CullingGroup API

由於使用 CullingGroups 並不總是非常簡單,因此將大量邏輯封裝在管理器類後面可能會有所幫助。

以下是這樣一位經理如何運作的藍圖。

using UnityEngine;
using System;
public interface ICullingGroupManager
{
    int ReserveSphere();
    void ReleaseSphere(int sphereIndex);
    void SetPosition(int sphereIndex, Vector3 position);
    void SetRadius(int sphereIndex, float radius);
    void SetCullingEvent(int sphereIndex, Action<CullingGroupEvent> sphere);
}

它的要點是你從管理器中保留一個剔除球體,它返回保留球體的索引。然後使用給定的索引來操作保留的球體。