Skip to content

Commit 2f2b56a

Browse files
authored
修复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版本判断
1 parent 79b3255 commit 2f2b56a

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

MCPForUnity/Editor/Services/Transport/Transports/WebSocketTransportClient.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ private async Task<string> ReceiveMessageAsync(CancellationToken token)
345345
return null;
346346
}
347347

348-
byte[] rentedBuffer = ArrayPool<byte>.Shared.Rent(8192);
348+
byte[] rentedBuffer = System.Buffers.ArrayPool<byte>.Shared.Rent(8192);
349349
var buffer = new ArraySegment<byte>(rentedBuffer);
350350
using var ms = new MemoryStream(8192);
351351

@@ -381,7 +381,7 @@ private async Task<string> ReceiveMessageAsync(CancellationToken token)
381381
}
382382
finally
383383
{
384-
ArrayPool<byte>.Shared.Return(rentedBuffer);
384+
System.Buffers.ArrayPool<byte>.Shared.Return(rentedBuffer);
385385
}
386386
}
387387

MCPForUnity/Runtime/Helpers/ScreenshotUtility.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ public static ScreenshotCaptureResult CaptureToAssetsFolder(string fileName = nu
4141

4242
// Use only the file name to let Unity decide the final location (per CaptureScreenshot docs).
4343
string captureName = Path.GetFileName(normalizedFullPath);
44+
#if UNITY_2022_1_OR_NEWER
4445
ScreenCapture.CaptureScreenshot(captureName, size);
46+
#endif
4547

4648
Debug.Log($"Screenshot requested: file='{captureName}' intendedFullPath='{normalizedFullPath}' persistentDataPath='{Application.persistentDataPath}'");
4749

0 commit comments

Comments
 (0)