Version: 2021.1

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 摄像机的速度。
speedMax SceneView 摄像机的最大速度。有效值在 [0.02, 99] 之间。
speedMin SceneView 摄像机的最小速度。有效值在 [0.01, 98] 之间。
speedNormalized SceneView 摄像机相对于当前最小/最大范围的归一化速度。有效值在 [0, 1] 之间。

构造函数

SceneView.CameraSettings创建新 CameraSettings 对象。
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961