Implement screenshot capture for Unity 2022.1+
Add conditional screenshot capture for Unity 2022.1 and newer.main
parent
2f2b56a20d
commit
a9878622ea
|
|
@ -41,12 +41,15 @@ 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
|
||||
|
||||
Debug.Log($"Screenshot requested: file='{captureName}' intendedFullPath='{normalizedFullPath}' persistentDataPath='{Application.persistentDataPath}'");
|
||||
|
||||
string projectRoot = GetProjectRootPath();
|
||||
string assetsRelativePath = normalizedFullPath;
|
||||
if (assetsRelativePath.StartsWith(projectRoot, StringComparison.OrdinalIgnoreCase))
|
||||
|
|
|
|||
Loading…
Reference in New Issue