Unity视图相机同步


主要用到APISceneView.lastActiveSceneView.camera

Game视图与Scene视图相机同步

Camera.main.transform.SetPositionAndRotation(SceneView.lastActiveSceneView.camera.transform.position, SceneView.lastActiveSceneView.camera.transform.rotation);

Scene视图与Game视图相机同步

Camera cameraMain = Camera.main;
var sceneView = SceneView.lastActiveSceneView;
if (sceneView != null)
{
    sceneView.cameraSettings.nearClip = cameraMain.nearClipPlane;
    sceneView.cameraSettings.fieldOfView = cameraMain.fieldOfView;
    sceneView.pivot = cameraMain.transform.position +
        cameraMain.transform.forward * sceneView.cameraDistance;
    sceneView.rotation = cameraMain.transform.rotation;
}

声明:有无之境|版权所有,违者必究|如未注明,均为原创|本网站采用BY-NC-SA协议进行授权

转载:转载请注明原文链接 - Unity视图相机同步


有无之境