Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Bug / Crash  Error when installing the latest
#1
Im using Unity 2022.2.19 HDRP, and I'm getting this error in your scripts:

Assets\Obi\Scripts\Common\Backends\Burst\DataStructures\NativeMultilevelGrid.cs(34,13): error CS0305: Using the generic type 'UnsafeList<T>' requires 1 type arguments

Assets\Obi\Scripts\Common\Backends\Burst\DataStructures\NativeMultilevelGrid.cs(88,36): error CS8377: The type 'NativeMultilevelGrid<T>.Cell<T>' must be a non-nullable value type, along with all fields at any level of nesting, in order to use it as parameter 'T' in the generic type or method 'NativeList<T>'

Please advise. Thanks.

No error in Unity 2021.3.25f1 LTS URP.
Reply
#2
(12-05-2023, 07:34 PM)AdamZ101 Wrote: Im using Unity 2022.2.19 HDRP, and I'm getting this error in your scripts:

Assets\Obi\Scripts\Common\Backends\Burst\DataStructures\NativeMultilevelGrid.cs(34,13): error CS0305: Using the generic type 'UnsafeList<T>' requires 1 type arguments

Assets\Obi\Scripts\Common\Backends\Burst\DataStructures\NativeMultilevelGrid.cs(88,36): error CS8377: The type 'NativeMultilevelGrid<T>.Cell<T>' must be a non-nullable value type, along with all fields at any level of nesting, in order to use it as parameter 'T' in the generic type or method 'NativeList<T>'

Please advise. Thanks.

No error in Unity 2021.3.25f1 LTS URP.

Hi,

This is because the latest version of the Collections package has different requirements for generic types, there's a relatively simple workaround: Change the definition of Cell<K> in NativeMultiLevelGrid.cs to look like this:

public struct Cell<K> where K : unmanaged, IEquatable<K>

Also, change UnsafeList to UnsafeList<K>, in the same file.

let me know if you need further help,

kind regards
Reply
#3
Hi, I still got errors after modifying the code to what you've mentioned above. unmanaged is already inherited, just added UnsafeList<K>.
I'm using Unity LTS 2022.3.1f1, Collections 2.1.4.


Code:
Assets/Obi/Scripts/Common/Backends/Burst/DataStructures/NativeMultilevelGrid.cs(39,32): error CS1729: 'UnsafeList<K>' does not contain a constructor that takes 1 arguments

Assets/Obi/Scripts/Common/Backends/Burst/DataStructures/NativeMultilevelGrid.cs(72,29): error CS1929: 'UnsafeList<K>' does not contain a definition for 'IndexOf' and the best extension method overload 'MemoryExtensions.IndexOf<K>(ReadOnlySpan<K>, ReadOnlySpan<K>)' requires a receiver of type 'ReadOnlySpan<K>'

Assets/Obi/Scripts/Common/Backends/Burst/DataStructures/NativeMultilevelGrid.cs(75,21): error CS1929: 'UnsafeList<K>' does not contain a definition for 'RemoveAtSwapBack' and the best extension method overload 'ListExtensions.RemoveAtSwapBack<K>(List<K>, int)' requires a receiver of type 'List<K>'

(12-06-2023, 01:27 AM)Ryle Cook Wrote: Hi, I still got errors after modifying the code to what you've mentioned above. unmanaged is already inherited, just added UnsafeList<K>.
I'm using Unity LTS 2022.3.1f1, Collections 2.1.4.


Code:
Assets/Obi/Scripts/Common/Backends/Burst/DataStructures/NativeMultilevelGrid.cs(39,32): error CS1729: 'UnsafeList<K>' does not contain a constructor that takes 1 arguments

Assets/Obi/Scripts/Common/Backends/Burst/DataStructures/NativeMultilevelGrid.cs(72,29): error CS1929: 'UnsafeList<K>' does not contain a definition for 'IndexOf' and the best extension method overload 'MemoryExtensions.IndexOf<K>(ReadOnlySpan<K>, ReadOnlySpan<K>)' requires a receiver of type 'ReadOnlySpan<K>'

Assets/Obi/Scripts/Common/Backends/Burst/DataStructures/NativeMultilevelGrid.cs(75,21): error CS1929: 'UnsafeList<K>' does not contain a definition for 'RemoveAtSwapBack' and the best extension method overload 'ListExtensions.RemoveAtSwapBack<K>(List<K>, int)' requires a receiver of type 'List<K>'

I found the same(or similar?) issue, and fixed the first error. To fix the last two errors I deleted <K> type to make compiler deduct automatically, but I'm not sure that is the right way. Anyway I tested a few samples and it works.
Reply