修复ArrayPool可能会产生报错的问题 (#451)

* Fixed ArrayPool conflict with CString.dll ArrayPool in Tolua

Fixed ArrayPool conflict with CString.dll ArrayPool in Tolua

* ScreenCapture在Unity2022中才支持

ScreenCapture在Unity2022中才支持,增加Unity版本判断
main
Evan 2025-12-11 01:14:30 +08:00 committed by GitHub
parent 79b3255d0a
commit 2f2b56a20d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 2 deletions

View File

@ -345,7 +345,7 @@ namespace MCPForUnity.Editor.Services.Transport.Transports
return null;
}
byte[] rentedBuffer = ArrayPool<byte>.Shared.Rent(8192);
byte[] rentedBuffer = System.Buffers.ArrayPool<byte>.Shared.Rent(8192);
var buffer = new ArraySegment<byte>(rentedBuffer);
using var ms = new MemoryStream(8192);
@ -381,7 +381,7 @@ namespace MCPForUnity.Editor.Services.Transport.Transports
}
finally
{
ArrayPool<byte>.Shared.Return(rentedBuffer);
System.Buffers.ArrayPool<byte>.Shared.Return(rentedBuffer);
}
}

View File

@ -41,7 +41,9 @@ 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);
#endif
Debug.Log($"Screenshot requested: file='{captureName}' intendedFullPath='{normalizedFullPath}' persistentDataPath='{Application.persistentDataPath}'");