使用此类可设置 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.02, 99] 之间。 |
speedMin | SceneView 摄像机的最小速度。有效值在 [0.01, 98] 之间。 |
speedNormalized | SceneView 摄像机相对于当前最小/最大范围的归一化速度。有效值在 [0, 1] 之间。 |
SceneView.CameraSettings | 创建新 CameraSettings 对象。 |
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.