Skip to content

Commit 6f3a50a

Browse files
authored
Merge pull request #1 from seannowotny/patch-1
Make compatible with Unity 2020 LTS
2 parents 38eb7fc + eeae070 commit 6f3a50a

File tree

7 files changed

+38
-30
lines changed

7 files changed

+38
-30
lines changed

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,18 @@ Provides extensions to Unity's `NativeArray<T>` that make using .NET's Span<T> w
2323
#### Prerequisites
2424

2525
```
26-
Unity 2021.3.x
26+
Unity 2020.3.x
27+
(Unity 2021.3.x is the recommended version however)
2728
```
2829

2930
(Newer Unity versions should be fine as well)
3031

32+
#### Unity 2020.3.x Prerequisites
33+
34+
**IF YOU ARE USING UNITY 2020.3.x WITH THIS PACKAGE, READ THIS**. (Newer versions do not need this step!)
35+
36+
`System.Memory` dll is required (this is where `Span<T>` use to come from). This package it self has no direct dependent installation method for `System.Memory`. You can either install it directly into your Unity project from [NuGet](https://www.nuget.org/packages/System.Memory) (by extracting it from the `.nupkg` file), or via an automatic seamless UPM integration, such as [Voltstro UPM](https://github.com/Voltstro/VoltstroUPM#using-unitynuget-packages), [OpenUPM](https://openupm.com/nuget/), or [UnityNuGet](https://github.com/xoofx/UnityNuGet).
37+
3138
### Installation Methods
3239

3340
There are three main sources on how you can install this package. Pick which ever one suites you the best!

Runtime/SpanExtensions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ public static NativeArray<T> ToNativeArray<T>(this Span<T> source, Allocator all
5555
public static NativeArray<T> ToNativeArray<T>(this ReadOnlySpan<T> source, Allocator allocator)
5656
where T : unmanaged
5757
{
58-
NativeArray<T> newArray = new(source.Length, allocator, NativeArrayOptions.UninitializedMemory);
58+
NativeArray<T> newArray = new NativeArray<T>(source.Length, allocator, NativeArrayOptions.UninitializedMemory);
5959
newArray.CopyFrom(source);
6060
return newArray;
6161
}
6262
}
63-
}
63+
}

Tests/Runtime/NativeArrayExtensionsTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public void CopyFromTest<T>(T[] testData)
1313
where T : unmanaged
1414
{
1515
NativeArray<T> testNativeArray =
16-
new(testData.Length, Allocator.Temp, NativeArrayOptions.UninitializedMemory);
16+
new NativeArray<T>(testData.Length, Allocator.Temp, NativeArrayOptions.UninitializedMemory);
1717
try
1818
{
1919
Assert.IsTrue(testNativeArray.IsCreated);
@@ -35,7 +35,7 @@ public void CopyFromTest<T>(T[] testData)
3535
public void CopyTo<T>(T[] testData)
3636
where T : unmanaged
3737
{
38-
NativeArray<T> testNativeArray = new(testData, Allocator.Temp);
38+
NativeArray<T> testNativeArray = new NativeArray<T>(testData, Allocator.Temp);
3939
try
4040
{
4141
Assert.IsTrue(testNativeArray.IsCreated);

Tests/Runtime/NativeSliceExtensionsTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public void CopyFromTest<T>(T[] testData)
1313
where T : unmanaged
1414
{
1515
NativeArray<T> testNativeArray =
16-
new(testData.Length, Allocator.Temp, NativeArrayOptions.UninitializedMemory);
16+
new NativeArray<T>(testData.Length, Allocator.Temp, NativeArrayOptions.UninitializedMemory);
1717
NativeSlice<T> testNativeSlice = testNativeArray.Slice();
1818

1919
try
@@ -37,7 +37,7 @@ public void CopyFromTest<T>(T[] testData)
3737
public void CopyTo<T>(T[] testData)
3838
where T : unmanaged
3939
{
40-
NativeArray<T> testNativeArray = new(testData, Allocator.Temp);
40+
NativeArray<T> testNativeArray = new NativeArray<T>(testData, Allocator.Temp);
4141
NativeSlice<T> testNativeSlice = testNativeArray.Slice();
4242

4343
try

Tests/Runtime/SpanExtensionsTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public void CopyToReadOnlyTest<T>(T[] testData)
1313
where T : unmanaged
1414
{
1515
NativeArray<T> testNativeArray =
16-
new(testData.Length, Allocator.Temp, NativeArrayOptions.UninitializedMemory);
16+
new NativeArray<T>(testData.Length, Allocator.Temp, NativeArrayOptions.UninitializedMemory);
1717

1818
try
1919
{
@@ -37,7 +37,7 @@ public void CopyToTest<T>(T[] testData)
3737
where T : unmanaged
3838
{
3939
NativeArray<T> testNativeArray =
40-
new(testData.Length, Allocator.Temp, NativeArrayOptions.UninitializedMemory);
40+
new NativeArray<T>(testData.Length, Allocator.Temp, NativeArrayOptions.UninitializedMemory);
4141

4242
try
4343
{
Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
11
{
2-
"name": "VoltstroStudios.NativeArraySpanExtensions.Tests",
3-
"rootNamespace": "VoltstroStudios.NativeArraySpanExtensions.Tests",
4-
"references": [
5-
"UnityEngine.TestRunner",
6-
"UnityEditor.TestRunner",
7-
"VoltstroStudios.NativeArraySpanExtensions"
8-
],
9-
"includePlatforms": [],
10-
"excludePlatforms": [],
11-
"allowUnsafeCode": false,
12-
"overrideReferences": true,
13-
"precompiledReferences": [
14-
"nunit.framework.dll"
15-
],
16-
"autoReferenced": false,
17-
"defineConstraints": [
18-
"UNITY_INCLUDE_TESTS"
19-
],
20-
"versionDefines": [],
21-
"noEngineReferences": false
2+
"name": "VoltstroStudios.NativeArraySpanExtensions.Tests",
3+
"rootNamespace": "VoltstroStudios.NativeArraySpanExtensions.Tests",
4+
"references": [
5+
"UnityEngine.TestRunner",
6+
"UnityEditor.TestRunner",
7+
"VoltstroStudios.NativeArraySpanExtensions"
8+
],
9+
"includePlatforms": [],
10+
"excludePlatforms": [],
11+
"allowUnsafeCode": false,
12+
"overrideReferences": true,
13+
"precompiledReferences": [
14+
"nunit.framework.dll",
15+
"System.Memory.dll"
16+
],
17+
"autoReferenced": false,
18+
"defineConstraints": [
19+
"UNITY_INCLUDE_TESTS"
20+
],
21+
"versionDefines": [],
22+
"noEngineReferences": false
2223
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"displayName": "Native Array Span Extensions",
44
"version": "1.0.0",
55
"description": "Provides extensions to Unity's NativeArray that make using .NET's Span<T> with them easier.",
6-
"unity": "2021.3",
6+
"unity": "2020.3",
77
"keywords": [
88
"native",
99
"nativearray",

0 commit comments

Comments
 (0)