21-02-2023, 08:41 AM
(This post was last modified: 21-02-2023, 08:43 AM by josemendez.)
(20-02-2023, 09:33 PM)ImpossibleRob Wrote: The documentation how to activate the burst solver is still stating rather old version numbers it seems. I try to get it running in 2023.1 but there Burst is quite advanced and the collections package does not contain needed types anymore so there will be many compile errors.Hi there!
How can I get the Burst backend properly activated in the new Unity and Burst versions?
I'm aware of this, working on an update. Latest Collections package version has replaced UnsafeList with a generic version, and changed the type restriction for generic containers.
Open up NativeMultilevelGrid.cs in your project, and replace the Cell<K> struct with this one, which uses UnsafeList<T> instead of UnsafeList:
Code:
public struct Cell<K> where K : unmanaged, IEquatable<K>
{
int4 coords;
UnsafeList<K> contents;
public Cell(int4 coords)
{
this.coords = coords;
contents = new UnsafeList<K>(4,Allocator.Persistent);
}
public int4 Coords
{
get { return coords; }
}
public int Length
{
get { return contents.Length; }
}
public void* ContentsPointer
{
get { return contents.Ptr; }
}
public K this[int index]
{
get
{
return contents.ElementAt(index);
}
}
public void Add(K entity)
{
contents.Add(entity);
}
public bool Remove(K entity)
{
int index = contents.IndexOf(entity);
if (index >= 0)
{
contents.RemoveAtSwapBack(index);
return true;
}
return false;
}
public void Dispose()
{
contents.Dispose();
}
}
In the same file, change the declaration of NativeMultilevelGrid to:
Quote:public unsafe struct NativeMultilevelGrid<T> : IDisposable where T : unmanaged, IEquatable<T>
Any other "the type <type> must be a non-nullable value type along with all fields at any level of nesting" errors that pop up are solved the same way: changing generic constraints from struct to unmanaged.
This should allow the Burst backend to work with the latest Collections package versions. Let me know if I can be of further help,
kind regards