Recursive Nullable Struct Crashes Editor

I am creating a struct that works like a chain of data. My struct looks like this:

public struct MyStruct
{
    public MyStruct? s;
}

Whenever the Editor tries to complie this code, it crashes. Is there a way to fix this?

2 Likes

This is because this effectively creates an infinite sized datastructure, as nullables are also structs.
However i don’t understand why this doesnt give a compiler error, as it does show a compiler error when using a regular dotnet core 7.2 project

1 Like

you cant do it like this sadly. if you need it to be a struct (because burst or whatever) you need to work with unsafe pointers

1 Like