对齐场景中的摄像机

Babybus-u3d技术交流-对齐场景中的摄像机

using UnityEngine;

using System.Collections;

using UnityEditor;

public class CameraContextMenu
{

[MenuItem("CONTEXT/Camera/Align With View")]

static void AlignWithView(MenuCommand menuCommand)

{

    Undo.RecordObject(menuCommand.context, "AlignWithView");


    var camera = menuCommand.context as Camera;

    var sceneViewCamera = SceneView.currentDrawingSceneView.camera;
   camera.transform.position = sceneViewCamera.transform.position;

    camera.transform.rotation = sceneViewCamera.transform.rotation;


    camera.isOrthoGraphic = sceneViewCamera.isOrthoGraphic;

    camera.fieldOfView = sceneViewCamera.fieldOfView;

}

}

1.png
2.png

你可能感兴趣的:(对齐场景中的摄像机)