Skip to content

Commit bfda08a

Browse files
author
Jiang Yin
committed
修改Unity2019 Android读取StreamingAsset报错的问题
1 parent 172104f commit bfda08a

File tree

1 file changed

+0
-17
lines changed

1 file changed

+0
-17
lines changed

Scripts/Runtime/FileSystem/AndroidFileSystemStream.cs

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -180,11 +180,7 @@ protected override int ReadByte()
180180
/// <returns>实际读取了多少字节。</returns>
181181
protected override int Read(byte[] buffer, int startIndex, int length)
182182
{
183-
#if UNITY_2019_1_OR_NEWER
184-
sbyte[] result = null;
185-
#else
186183
byte[] result = null;
187-
#endif
188184
int bytesRead = InternalRead(length, out result);
189185
Array.Copy(result, 0, buffer, startIndex, bytesRead);
190186
return bytesRead;
@@ -247,17 +243,9 @@ private int InternalRead()
247243
return m_FileStream.Call<int>("read");
248244
}
249245

250-
#if UNITY_2019_1_OR_NEWER
251-
private int InternalRead(int length, out sbyte[] result)
252-
#else
253246
private int InternalRead(int length, out byte[] result)
254-
#endif
255247
{
256-
#if UNITY_2019_1_OR_NEWER
257-
IntPtr resultPtr = AndroidJNI.NewSByteArray(length);
258-
#else
259248
IntPtr resultPtr = AndroidJNI.NewByteArray(length);
260-
#endif
261249
int offset = 0;
262250
int bytesLeft = length;
263251
while (bytesLeft > 0)
@@ -275,12 +263,7 @@ private int InternalRead(int length, out byte[] result)
275263
bytesLeft -= bytesRead;
276264
}
277265

278-
#if UNITY_2019_1_OR_NEWER
279-
result = AndroidJNI.FromSByteArray(resultPtr);
280-
#else
281266
result = AndroidJNI.FromByteArray(resultPtr);
282-
#endif
283-
284267
AndroidJNI.DeleteLocalRef(resultPtr);
285268
return offset;
286269
}

0 commit comments

Comments
 (0)