Version: 2022.3

CameraSettings

class in UnityEditor

切换到手册

描述

使用此类可设置 SceneView 摄像机属性。

// Create a folder (right click in the Assets directory, click Create>Folder)
// and name it Editor if one doesn't exist already. Create a new C# script called CustomSettings
// and place it in that folder.

// This script creates a new menu item Edit>SceneView Settings>Update Camera Settings in the main menu. // Use it to update the Camera settings in the Scene view.

using UnityEditor;

public class CustomSettings { [MenuItem("Edit/SceneView Settings/Update Camera Settings")] static void UpdateCameraSettings() { SceneView.CameraSettings settings = new SceneView.CameraSettings(); settings.accelerationEnabled = false; settings.speedMin = 1f; settings.speedMax = 10f; settings.speed = 5f; settings.easingEnabled = true; settings.easingDuration = 0.6f; settings.dynamicClip = false; settings.fieldOfView = 120f; settings.nearClip = 0.01f; settings.farClip = 1000f; settings.occlusionCulling = true; SceneView sceneView = SceneView.lastActiveSceneView; sceneView.cameraSettings = settings; } }

变量

accelerationEnabled在 SceneView 中启用摄像机移动加速。这会使摄像机在移动过程中加速。
dynamicClip启用时,将计算相对于场景视口大小的 SceneView 摄像机近和远裁剪面。而禁用时,使用 nearClip 和 farClip。
easingDuration SceneView 摄像机的速度加速到其初始全速所需的时间。以秒为测量单位。有效值在 [0.1, 2] 之间。
easingEnabled在 SceneView 中启用摄像机移动缓动。这使摄像机在开始移动时缓入,而在停止时缓出。
farClip离 SceneView 摄像机的最远绘制点。有效最小值为 0.02。
fieldOfViewThe height of the view angle for the SceneView Camera. Measured in degrees vertically, or along the local Y axis.
nearClip到 SceneView 摄像机的最近绘制点。有效最小值为 0.01。
occlusionCulling在 SceneView 中启用遮挡剔除。这样可以防止 Unity 渲染摄像机看不到的 GameObjects(因为它们被其他 GameObjects 所遮挡)。
speed SceneView 摄像机的速度。
speedMaxThe maximum speed of the SceneView Camera. Valid values are between [0.0002, 10000].
speedMinThe minimum speed of the SceneView Camera. Valid values are between [0.0001, 9999].
speedNormalized SceneView 摄像机相对于当前最小/最大范围的归一化速度。有效值在 [0, 1] 之间。

构造函数

SceneView.CameraSettings创建新 CameraSettings 对象。