Version: 2021.3

Camera.cullingMatrix

切换到手册
public Matrix4x4 cullingMatrix ;

描述

为摄像机设置一个自定义矩阵,以用于所有剔除查询。

通过调用 ResetCullingMatrix 禁用该设置以前,设置持续有效。

在必须以相同方式剔除多个摄像机以渲染反射等特效的情况下,自定义剔除矩阵非常有用。

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour { Camera cullingCamera;

void Awake() { cullingCamera = gameObject.AddComponent<Camera>(); SetMainCameraCustomCullingMatrix(new Vector3(10.0f, 10.0f, 10.0f), Vector3.zero); }

void SetMainCameraCustomCullingMatrix(Vector3 cameraPosition, Vector3 lookAtPosition) { transform.position = cameraPosition; transform.LookAt(lookAtPosition); Camera.main.cullingMatrix = cullingCamera.projectionMatrix * cullingCamera.worldToCameraMatrix; }

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