@@ -602,23 +602,7 @@ private static object CaptureScreenshot(SceneCommand cmd)
602602
603603 AssetDatabase . ImportAsset ( result . AssetsRelativePath , ImportAssetOptions . ForceSynchronousImport ) ;
604604 string message = $ "Screenshot captured to '{ result . AssetsRelativePath } ' (camera: { targetCamera . name } ).";
605-
606- var data = new Dictionary < string , object >
607- {
608- { "path" , result . AssetsRelativePath } ,
609- { "fullPath" , result . FullPath } ,
610- { "superSize" , result . SuperSize } ,
611- { "isAsync" , false } ,
612- { "camera" , targetCamera . name } ,
613- { "captureSource" , "game_view" } ,
614- } ;
615- if ( includeImage && result . ImageBase64 != null )
616- {
617- data [ "imageBase64" ] = result . ImageBase64 ;
618- data [ "imageWidth" ] = result . ImageWidth ;
619- data [ "imageHeight" ] = result . ImageHeight ;
620- }
621- return new SuccessResponse ( message , data ) ;
605+ return new SuccessResponse ( message , BuildScreenshotResponseData ( result , targetCamera . name , includeImage ) ) ;
622606 }
623607
624608 if ( includeImage && Application . isPlaying )
@@ -632,23 +616,7 @@ private static object CaptureScreenshot(SceneCommand cmd)
632616 AssetDatabase . ImportAsset ( result . AssetsRelativePath , ImportAssetOptions . ForceSynchronousImport ) ;
633617 string cameraName = Camera . main != null ? Camera . main . name : "composited" ;
634618 string message = $ "Screenshot captured to '{ result . AssetsRelativePath } ' (camera: { cameraName } ).";
635-
636- var data = new Dictionary < string , object >
637- {
638- { "path" , result . AssetsRelativePath } ,
639- { "fullPath" , result . FullPath } ,
640- { "superSize" , result . SuperSize } ,
641- { "isAsync" , false } ,
642- { "camera" , cameraName } ,
643- { "captureSource" , "game_view" } ,
644- } ;
645- if ( result . ImageBase64 != null )
646- {
647- data [ "imageBase64" ] = result . ImageBase64 ;
648- data [ "imageWidth" ] = result . ImageWidth ;
649- data [ "imageHeight" ] = result . ImageHeight ;
650- }
651- return new SuccessResponse ( message , data ) ;
619+ return new SuccessResponse ( message , BuildScreenshotResponseData ( result , cameraName , includeImage : true ) ) ;
652620 }
653621
654622 if ( includeImage )
@@ -673,23 +641,7 @@ private static object CaptureScreenshot(SceneCommand cmd)
673641
674642 AssetDatabase . ImportAsset ( result . AssetsRelativePath , ImportAssetOptions . ForceSynchronousImport ) ;
675643 string message = $ "Screenshot captured to '{ result . AssetsRelativePath } ' (camera: { targetCamera . name } ).";
676-
677- var data = new Dictionary < string , object >
678- {
679- { "path" , result . AssetsRelativePath } ,
680- { "fullPath" , result . FullPath } ,
681- { "superSize" , result . SuperSize } ,
682- { "isAsync" , false } ,
683- { "camera" , targetCamera . name } ,
684- { "captureSource" , "game_view" } ,
685- } ;
686- if ( includeImage && result . ImageBase64 != null )
687- {
688- data [ "imageBase64" ] = result . ImageBase64 ;
689- data [ "imageWidth" ] = result . ImageWidth ;
690- data [ "imageHeight" ] = result . ImageHeight ;
691- }
692- return new SuccessResponse ( message , data ) ;
644+ return new SuccessResponse ( message , BuildScreenshotResponseData ( result , targetCamera . name , includeImage ) ) ;
693645 }
694646
695647 // Default path: use ScreenCapture API if available, camera fallback otherwise
@@ -746,6 +698,31 @@ private static object CaptureScreenshot(SceneCommand cmd)
746698 }
747699 }
748700
701+ private static Dictionary < string , object > BuildScreenshotResponseData (
702+ ScreenshotCaptureResult result ,
703+ string cameraName ,
704+ bool includeImage )
705+ {
706+ var data = new Dictionary < string , object >
707+ {
708+ { "path" , result . AssetsRelativePath } ,
709+ { "fullPath" , result . FullPath } ,
710+ { "superSize" , result . SuperSize } ,
711+ { "isAsync" , false } ,
712+ { "camera" , cameraName } ,
713+ { "captureSource" , "game_view" } ,
714+ } ;
715+
716+ if ( includeImage && result . ImageBase64 != null )
717+ {
718+ data [ "imageBase64" ] = result . ImageBase64 ;
719+ data [ "imageWidth" ] = result . ImageWidth ;
720+ data [ "imageHeight" ] = result . ImageHeight ;
721+ }
722+
723+ return data ;
724+ }
725+
749726 private static object CaptureSceneViewScreenshot (
750727 SceneCommand cmd ,
751728 string fileName ,
0 commit comments