* Update ScreenshotUtility.cs Fix issue in issue#465 * Update ScreenshotUtility.csmain
parent
df906cb747
commit
90758f19f4
|
|
@ -42,14 +42,7 @@ namespace MCPForUnity.Runtime.Helpers
|
|||
// Use only the file name to let Unity decide the final location (per CaptureScreenshot docs).
|
||||
string captureName = Path.GetFileName(normalizedFullPath);
|
||||
|
||||
|
||||
#if UNITY_2022_1_OR_NEWER
|
||||
ScreenCapture.CaptureScreenshot(captureName, size);
|
||||
#else
|
||||
Debug.LogWarning("ScreenCapture is supported after Unity 2022.1. Using main camera capture as fallback.");
|
||||
CaptureFromCameraToAssetsFolder(Camera.main, captureName, size, false);
|
||||
#endif
|
||||
|
||||
// Use Asset folder for ScreenCapture.CaptureScreenshot to ensure write to asset rather than project root
|
||||
string projectRoot = GetProjectRootPath();
|
||||
string assetsRelativePath = normalizedFullPath;
|
||||
if (assetsRelativePath.StartsWith(projectRoot, StringComparison.OrdinalIgnoreCase))
|
||||
|
|
@ -57,6 +50,13 @@ namespace MCPForUnity.Runtime.Helpers
|
|||
assetsRelativePath = assetsRelativePath.Substring(projectRoot.Length).TrimStart('/');
|
||||
}
|
||||
|
||||
#if UNITY_2022_1_OR_NEWER
|
||||
ScreenCapture.CaptureScreenshot(assetsRelativePath, size);
|
||||
#else
|
||||
Debug.LogWarning("ScreenCapture is supported after Unity 2022.1. Using main camera capture as fallback.");
|
||||
CaptureFromCameraToAssetsFolder(Camera.main, captureName, size, false);
|
||||
#endif
|
||||
|
||||
return new ScreenshotCaptureResult(
|
||||
normalizedFullPath,
|
||||
assetsRelativePath,
|
||||
|
|
|
|||
Loading…
Reference in New Issue