Unity engine support
Currently I am doing a lot of struggle to marshal data into Unity from external .NET process or external WebAssembly module.
It would be much better if this library would support Unity engine by default.
As you may know, Unity supports only up to .NET 4.8 or .NET Standard 2.1, see docs.
I managed to compile library to .NET Standard 2.1, which runs fine in .NET 7 executable, but gives some weird errors in Unity, like InvalidProtocolBufferException. Then there is Unity's custom AOT solution (called IL2CPP) which I haven't even tried to run with.
What do you think about it ?
A full exception could be useful for pinning down exactly what's going on here.
Is there a simple way to reproduce this in Unity? I have no familiarity with it
Ok, so here are the steps to reproduce it:
Compile library to .NET Standard 2.1
- Checkout this branch, here is comparison to main branch
- Build:
dotnet publish -c Release- you need to publish so you get all dependency DLLs in the same folder (which will also be .NET Standard 2.1 compatible)
Unity
- download Unity 2022.3.13
- clone repro project: https://github.com/in0finite/DemoFileNetUnityExample
- copy all DLLs from
DemoFile\bin\Release\netstandard2.1\publishtoDemoFileNetUnityExample/Assets - launch Unity and open project
- when it starts, hit Play button (on top of screen)
- select Demo file
- the error will be shown in Console:
Exception: LeavePvs on non-existent entity 176
DemoFile.DemoParser.OnPacketEntities (CSVCMsg_PacketEntities msg) (at <ec978e4798c440c88601902d9135d2e1>:0)
DemoFile.PacketEvents.ParseNetMessage (System.Int32 msgType, System.ReadOnlySpan`1[T] buf) (at <ec978e4798c440c88601902d9135d2e1>:0)
DemoFile.DemoParser.OnDemoPacket (CDemoPacket msg) (at <ec978e4798c440c88601902d9135d2e1>:0)
DemoFile.DemoEvents.ReadDemoCommand (EDemoCommands msgType, System.ReadOnlySpan`1[T] buffer) (at <ec978e4798c440c88601902d9135d2e1>:0)
DemoFile.DemoParser.MoveNextAsync (System.Threading.CancellationToken cancellationToken) (at <ec978e4798c440c88601902d9135d2e1>:0)
Let me know if you need help.