lachee / unity-named-pipes Goto Github PK
View Code? Open in Web Editor NEWA native named pipe wrapper for Unity3D
License: MIT License
A native named pipe wrapper for Unity3D
License: MIT License
If I want to communicate between Unity and a process in another language (e.g. python, C++) how can I do it?
This causes specifically with the https://github.com/Lachee/discord-rpc-csharp library for games built with unity to crash on linux as they reach the max number of open file descriptors because of all of the dangling sockets:
I built a simple C++ program to reproduce this behavior https://gist.github.com/mdsitton/95fc0040d01cdf198961cb72255c234a:
NamedPipe 24436 deck 154u unix 0x0000000032901640 0t0 1758654 type=STREAM (UNCONNECTED)
NamedPipe 24436 deck 155u unix 0x00000000d5c3a1e9 0t0 1758660 type=STREAM (UNCONNECTED)
NamedPipe 24436 deck 156u unix 0x00000000683a598f 0t0 1758661 type=STREAM (UNCONNECTED)
NamedPipe 24436 deck 157u unix 0x00000000c55ccb76 0t0 1758662 type=STREAM (UNCONNECTED)
NamedPipe 24436 deck 158u unix 0x00000000014525f2 0t0 1758663 type=STREAM (UNCONNECTED)
NamedPipe 24436 deck 159u unix 0x00000000d50b286d 0t0 1758664 type=STREAM (UNCONNECTED)
NamedPipe 24436 deck 160u unix 0x00000000e67ac18d 0t0 1758665 type=STREAM (UNCONNECTED)
NamedPipe 24436 deck 161u unix 0x00000000b56c7489 0t0 1758666 type=STREAM (UNCONNECTED)
NamedPipe 24436 deck 162u unix 0x000000005ec439e0 0t0 1758667 type=STREAM (UNCONNECTED)
NamedPipe 24436 deck 163u unix 0x0000000048697d99 0t0 1758668 type=STREAM (UNCONNECTED)
NamedPipe 24436 deck 164u unix 0x00000000134ceea6 0t0 1758669 type=STREAM (UNCONNECTED)
NamedPipe 24436 deck 165u unix 0x00000000d28c99e8 0t0 1758673 type=STREAM (UNCONNECTED)
NamedPipe 24436 deck 166u unix 0x0000000077915d8f 0t0 1758674 type=STREAM (UNCONNECTED)
NamedPipe 24436 deck 167u unix 0x000000005b9e8cf4 0t0 1758675 type=STREAM (UNCONNECTED)
NamedPipe 24436 deck 168u unix 0x00000000427a36ff 0t0 1758676 type=STREAM (UNCONNECTED)
NamedPipe 24436 deck 169u unix 0x00000000a20791de 0t0 1758677 type=STREAM (UNCONNECTED)
NamedPipe 24436 deck 170u unix 0x00000000fea049c2 0t0 1758678 type=STREAM (UNCONNECTED)
NamedPipe 24436 deck 171u unix 0x0000000096185ac3 0t0 1758679 type=STREAM (UNCONNECTED)
NamedPipe 24436 deck 172u unix 0x00000000095ce08f 0t0 1758680 type=STREAM (UNCONNECTED)
NamedPipe 24436 deck 173u unix 0x000000008790cba8 0t0 1758681 type=STREAM (UNCONNECTED)
NamedPipe 24436 deck 174u unix 0x000000000c4dd30c 0t0 1758682 type=STREAM (UNCONNECTED)
NamedPipe 24436 deck 175u unix 0x00000000d8bd7810 0t0 1758688 type=STREAM (UNCONNECTED)
NamedPipe 24436 deck 176u unix 0x00000000b0c390bf 0t0 1758689 type=STREAM (UNCONNECTED)
NamedPipe 24436 deck 177u unix 0x0000000073576f72 0t0 1758690 type=STREAM (UNCONNECTED)
NamedPipe 24436 deck 178u unix 0x00000000d50b8cda 0t0 1758691 type=STREAM (UNCONNECTED)
NamedPipe 24436 deck 179u unix 0x0000000078206672 0t0 1758692 type=STREAM (UNCONNECTED)
NamedPipe 24436 deck 180u unix 0x00000000ea085407 0t0 1758693 type=STREAM (UNCONNECTED)
NamedPipe 24436 deck 181u unix 0x00000000720ba526 0t0 1758694 type=STREAM (UNCONNECTED)
NamedPipe 24436 deck 182u unix 0x00000000f357ca4e 0t0 1758695 type=STREAM (UNCONNECTED)
NamedPipe 24436 deck 183u unix 0x00000000784fe663 0t0 1758696 type=STREAM (UNCONNECTED)
NamedPipe 24436 deck 184u unix 0x000000002008e488 0t0 1758697 type=STREAM (UNCONNECTED)
NamedPipe 24436 deck 185u unix 0x00000000390b7635 0t0 1758702 type=STREAM (UNCONNECTED)
NamedPipe 24436 deck 186u unix 0x00000000e8415e72 0t0 1758703 type=STREAM (UNCONNECTED)
NamedPipe 24436 deck 187u unix 0x00000000fcddf6dd 0t0 1758704 type=STREAM (UNCONNECTED)
NamedPipe 24436 deck 188u unix 0x0000000062727928 0t0 1758705 type=STREAM (UNCONNECTED)
NamedPipe 24436 deck 189u unix 0x00000000fa2d3c4a 0t0 1758706 type=STREAM (UNCONNECTED)
NamedPipe 24436 deck 190u unix 0x00000000a7262f67 0t0 1758707 type=STREAM (UNCONNECTED)
NamedPipe 24436 deck 191u unix 0x00000000cac478ad 0t0 1758708 type=STREAM (UNCONNECTED)
NamedPipe 24436 deck 192u unix 0x000000009f51dda5 0t0 1758709 type=STREAM (UNCONNECTED)
NamedPipe 24436 deck 193u unix 0x0000000070f71bcb 0t0 1758710 type=STREAM (UNCONNECTED)
NamedPipe 24436 deck 194u unix 0x00000000f631da32 0t0 1758711 type=STREAM (UNCONNECTED)
(deck@steamdeck ~)$ lsof -p 24436 | grep -c STREAM
270
The issue occurs here:
https://github.com/Lachee/unity-named-pipes/blob/master/UnityNamedPipe.Native/connection_unix.cpp#L97
This happens because isOpened is only set to true if a connection is made to the input path, but we still have a socket which doesn't get closed properly.
I have problem using this plugin with unity. After compilation of the game, there are no plugin (NativeNamedPipe.so) in /Contents/Frameworks/MonoEmbedRuntime/osx/ directory. Plugin code in unity in /Assets/Plugins/x86_64 directory. So on launch, game crushed with System.DLLNotFoundException: NativeNamedPipe error. "Fallback handler could not load library".
Because library is just missing.
The plugin included for Unix is a .so
file but Unity requires a .bundle
file for Mac OS:
For cross platform plug-ins you must include the .bundle (for Mac), .dll (for Windows), and .so (for Linux) files in the Plugins folder. No further work is then required on your side - Unity automatically picks the right plug-in for the target platform and includes it with the player.
I don't need a Mac build bad enough to create a bundle right now, just leaving this here for anyone else that runs into the issue.
Originally posted by @jelling in #2 (comment)
Is there a Unity package that contains a DLL for 32-bits systems?
It shows build failing and there are no instructions on how to actually use the package. Just curious if it is fully functional, or still in development phase?
It looks like pipes do work, but its more because mono never finished async implementation in the pipes. I have a .NET 5 server that runs a Unity instance and the server works fine using async but have to use Hard Threads or your library to get it to work on unity's side. I was about to give up and just use TcpClient/TcpServer:P
I'm using NamedPipes to tell Streamlabs OBS to change scene, thanks to this dll, i got it working in the Unity Editor, but it doesnt work when I make my build. Is there something that needs to be changed in my project settings?
(I have already set Api Compatibility Level to .NET 4.x, but that is the only thing i have changed)
What is the license of this library?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.