使用此类设置 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 对象。 |
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.