UnityEditor.SceneView.lastActiveSceneView.cameraでシーンのカメラを取得できるようなので、下記のようにしました
C#
1[ContextMenu ("capture")]
2void CaptureSceneCameraView ()
3{
4 // 保存するパス
5 var filePath = string.Format("{0}/image.png", Application.dataPath);
6 // シーンカメラのテクスチャを取得する
7 var renderTextureRef = UnityEditor.SceneView.lastActiveSceneView.camera.activeTexture;
8 // Texture2Dに書き込む
9 Texture2D tex = new Texture2D(renderTextureRef.width, renderTextureRef.height, TextureFormat.RGB24, false);
10 RenderTexture.active = renderTextureRef;
11 tex.ReadPixels(new Rect(0, 0, renderTextureRef.width, renderTextureRef.height), 0, 0);
12 tex.Apply();
13
14 // PNGに変換
15 byte[] bytes = tex.EncodeToPNG();
16 // 保存する
17 File.WriteAllBytes(filePath, bytes);
18}
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。