使用此类设置 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。 |
fieldOfView | SceneView 相机的视角高度。以度为单位垂直测量,或沿着局部 Y 轴测量。 |
nearClip | SceneView 相机最近处的绘制点。有效最小值为 0.01。 |
occlusionCulling | 在 SceneView 中启用遮挡剔除。这将阻止 Unity 渲染相机无法看到的 GameObjects,因为它们被其他 GameObjects 遮挡。 |
speed | SceneView 相机的速度。 |
speedMax | SceneView 相机的最大速度。有效值为 [0.0002, 10000]。 |
speedMin | SceneView 相机的最小速度。有效值为 [0.0001, 9999]。 |
speedNormalized | SceneView 相机的归一化速度,相对于当前最小/最大范围。有效值为 [0, 1]。 |
SceneView.CameraSettings | 创建一个新的 CameraSettings 对象。 |