Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Bug / Crash  Compatibility to Unity 2023.1
#2
(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. 

How can I get the Burst backend properly activated in the new Unity and Burst versions?
Hi there!

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
Reply


Messages In This Thread
Compatibility to Unity 2023.1 - by ImpossibleRob - 20-02-2023, 09:33 PM
RE: Compatibility to Unity 2023.1 - by josemendez - 21-02-2023, 08:41 AM
RE: Compatibility to Unity 2023.1 - by josemendez - 28-02-2023, 11:38 AM
RE: Compatibility to Unity 2023.1 - by josemendez - 28-02-2023, 03:12 PM
RE: Compatibility to Unity 2023.1 - by Oliran - 13-07-2023, 06:26 AM
RE: Compatibility to Unity 2023.1 - by josemendez - 13-07-2023, 06:33 AM