Version: 2023.2

Gizmos.CalculateLOD

切换到手册
public static float CalculateLOD (Vector3 position, float radius);

参数

position The centre of the gizmo in world space.
radius The maximum extent of the gizmo.

返回

float Returns a value between 0 and 1 that represents the level of detail for the gizmo.

描述

Determines the appropriate level of detail for a gizmo in the Scene view at a specified position with a specified radius.

A return value of 0 indicates the gizmo is not visible. The gizmo might not be visible because it is too small on the screen or because it is outside of the Scene view camera frustum. The return value is quantized to eighths to reduce the number of produced batches. This can be further controlled with the 'Fade Gizmos' options in the Gizmos menu.

using UnityEngine;

public class MyLODedComponent : MonoBehaviour { // Draw a blue sphere at the transform's position, fading out as it gets further away private void OnDrawGizmos() { float lod = Gizmos.CalculateLOD(transform.position, 1);

// Cull any gizmos that are too small or off screen if (lod == 0.0f) return;

// Fade the gizmos out so that they don't pop in and out when scrolling around the scene Gizmos.color = Color.blue * lod; Gizmos.DrawSphere(transform.position, 1); } }
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961