Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unity engine support #36

Open
in0finite opened this issue Jan 23, 2024 · 2 comments
Open

Unity engine support #36

in0finite opened this issue Jan 23, 2024 · 2 comments
Labels
type/feature New feature or request

Comments

@in0finite
Copy link
Contributor

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 ?

@saul
Copy link
Owner

saul commented Jan 28, 2024

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

@saul saul added the type/feature New feature or request label Jan 28, 2024
@in0finite
Copy link
Contributor Author

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\publish to DemoFileNetUnityExample/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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/feature New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants