* 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).
|
// Use only the file name to let Unity decide the final location (per CaptureScreenshot docs).
|
||||||
string captureName = Path.GetFileName(normalizedFullPath);
|
string captureName = Path.GetFileName(normalizedFullPath);
|
||||||
|
|
||||||
|
// Use Asset folder for ScreenCapture.CaptureScreenshot to ensure write to asset rather than project root
|
||||||
#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
|
|
||||||
|
|
||||||
string projectRoot = GetProjectRootPath();
|
string projectRoot = GetProjectRootPath();
|
||||||
string assetsRelativePath = normalizedFullPath;
|
string assetsRelativePath = normalizedFullPath;
|
||||||
if (assetsRelativePath.StartsWith(projectRoot, StringComparison.OrdinalIgnoreCase))
|
if (assetsRelativePath.StartsWith(projectRoot, StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
@ -57,6 +50,13 @@ namespace MCPForUnity.Runtime.Helpers
|
||||||
assetsRelativePath = assetsRelativePath.Substring(projectRoot.Length).TrimStart('/');
|
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(
|
return new ScreenshotCaptureResult(
|
||||||
normalizedFullPath,
|
normalizedFullPath,
|
||||||
assetsRelativePath,
|
assetsRelativePath,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue