以下の内容はhttps://baba-s.hatenablog.com/entry/2022/09/20/090000より取得しました。


【Unity】選択中の EditorWindow のスクリーンショットを撮影するエディタ拡張

ソースコード

using System;
using System.IO;
using UnityEditor;
using UnityEngine;

namespace Kogane.Internal
{
    internal static class EditorWindowCapturer
    {
        [MenuItem( "Kogane/選択中の EditorWindow をキャプチャ" )]
        private static void CaptureWindowScreenshot()
        {
            var editorWindow = EditorWindow.focusedWindow;
            var position     = editorWindow.position;
            var width        = ( int )position.width;
            var height       = ( int )position.height;

            var pixels = UnityEditorInternal.InternalEditorUtility.ReadScreenPixel
            (
                pixelPos: position.position,
                sizex: width,
                sizey: height
            );

            var texture = new Texture2D( width, height, TextureFormat.RGB24, false );
            texture.SetPixels( pixels );

            var bytes = texture.EncodeToPNG();
            var path  = DateTime.Now.ToString( "yyyy-MM-dd_HHmmss" ) + ".png";

            File.WriteAllBytes( path, bytes );
        }
    }
}

使用例

メニューを選択すると

選択中の EditorWindow のスクリーンショットが
Unity プロジェクトのフォルダに保存されます




以上の内容はhttps://baba-s.hatenablog.com/entry/2022/09/20/090000より取得しました。
このページはhttp://font.textar.tv/のウェブフォントを使用してます

不具合報告/要望等はこちらへお願いします。
モバイルやる夫Viewer Ver0.14