public void AddCullingBounds() { if (cullingGroup == null) { cullingGroup = new CullingGroup(); cullingGroup.targetCamera = Camera.main; cullingGroup.SetBoundingDistances(anim.lodDistances); cullingGroup.SetDistanceReferencePoint(Camera.main.transform); cullingGroup.onStateChanged = OnLodCullingGroupOnStateChangedHandler; } cullingBounds.Add(new BoundingSphere()); cullingGroup.SetBoundingSpheres(cullingBounds.buffer); cullingGroup.SetBoundingSphereCount(players.Count); }
/// <summary> /// 为新的PlayerMono添加/设置CullingBounds /// cullingGroup的目标相机设置为Camera.main(可能需要修改) /// </summary> public void AddCullingBounds() { if (cullingGroup == null) { cullingGroup = new CullingGroup(); cullingGroup.targetCamera = Camera.main; //设置LOD和Culling距离 cullingGroup.SetBoundingDistances(anim.lodDistances); //计算Distance的初始位置(Transform索引或Vector3固定点) cullingGroup.SetDistanceReferencePoint(Camera.main.transform); //距离发生改变时调用的回调函数 cullingGroup.onStateChanged = OnLodCullingGroupOnStateChangedHandler; } //为新的PlayerMono添加一个BoundingSphere,如何建立索引?(与Players的索引相同?) cullingBounds.Add(new BoundingSphere()); cullingGroup.SetBoundingSpheres(cullingBounds.buffer); cullingGroup.SetBoundingSphereCount(players.Count); }