HACK into your GAMES! (C# Named Pipes)
Вставка
- Опубліковано 3 жов 2024
- 🌍 Get my Complete Courses! ✅ unitycodemonke...
👍 Learn to make awesome games step-by-step from start to finish.
🎮 Get my Steam Games unitycodemonke...
💬 Here's how you can create a main Unity instance, like your game, and then make a second Unity app to control the first one.
This is what I used to make my livestream overlay where I have the characters on the main screen and a control panel on the second screen.
This is made using C# Named Pipes, NamedPipeServerStream and NamedPipeClientStream. Another approach you could use would be a TCP tunnel.
This is a pretty niche topic but it took me quite a while to get everything working right so I'm hoping this video helps someone who is searching for this topic just like I was.
Thanks!
Transparent Unity App! (Overlay, Assistant, Particles)
• Transparent Unity App!...
Code Monkey Livestreams
• Code Monkey Livestreams
How to: Use Named Pipes for Network Interprocess Communication
docs.microsoft...
What is JSON?
• What is JSON?
Unity Forum Thread
forum.unity.co...
🌍 Get Code Monkey on Steam!
👍 Interactive Tutorials, Complete Games and More!
✅ store.steampow...
If you have any questions post them in the comments and I'll do my best to answer them.
🔔 Subscribe for more Unity Tutorials / @codemonkeyunity
See you next time!
📍 Support on Patreon / unitycodemonkey
🤖 Join the Community Discord / discord
🎮 Grab the Game Bundle at unitycodemonke...
📝 Get the Code Monkey Utilities at unitycodemonke...
#unitytutorial #unity3d #gamedev #unity2d #unity #indiegame #gamedevelopment #madewithunity #indiedev
--------------------------------------------------------------------
Hello and Welcome!
I'm your Code Monkey and here you will learn everything about Game Development in Unity using C#.
I've been developing games for several years with 8 published games on Steam and now I'm sharing my knowledge to help you on your own game development journey.
I do Unity Tutorials on just about every topic, Unity Tutorials for Beginners and Unity Tutorials for Advanced users.
You can see my games at www.endlessloopstudios.com
--------------------------------------------------------------------
Other great Unity channels:
Brackeys - / brackeys
Dani - / @danidev
Jabrils - / @jabrils
BlackthornProd - / @blackthornprod
Sykoo - / sykootv
Jason Weimann - / @unity3dcollege
Jonas Tyroller - / @jonastyroller
--------------------------------------------------------------------
Website: unitycodemonke...
Twitter: / unitycodemonkey
Steam: store.steampow...
💬 Here's a very niche topic I had to research in order to make my livestream overlay. I'm planning another livestream this week so hit the bell icon!
🌐 Have you found the videos Helpful and Valuable?
❤️ Get my Courses unitycodemonkey.com/courses or my Steam Games 🎮 unitycodemonkey.com/gamebundle
Could you possibly link the issue thread you opened on Unity forums please? I failed to gooogle it.
Also thank you so much for your tutorial, it's invaluable to me, I needed to communicate two unity apps, I tried doing that with websockets and it was such a pain, thank youuuuu! 💝
Such unique tutorials are much more valuable than another "make your first platformer" type of tutorials. I think this is strong point of your channel (like an entire ECS series which was very helpful while this topic wasn't well covered by other channels) so I am really happy to see such videos even if I am not going to use this knowledge in near future.
Thanks!
I love obscure stuff like this. So nice to actually learn about something I hadn't heard of before.
(Commenting for the algorithm to pick this video up. I really like this channel and want it to do well).
Thanks! It does help a lot!
(Doing the same)
Congratulation u have reached a highest comment on this video 👍
Fair
Same same ^^
For game developers that are in the trenches so to speak, this is a great video. It’s hard to learn something new with Unity and C# after developing for years. Thanks for the good content!
This is exactly what I was thinking of looking into over the last 2 weeks! Great video!
DUUUDE! Love it! This is actually extremely handy. This not only opens many options for debugging or activating specific things on your game but various possibilities. Thanks for the share!
transparent unity app is exactly what I was searching a while ago.
It's an excellent way to make some truly unique things with Unity!
Awesome tutorial, I definitely think it's not niche, very simple and straight-forward demonstration of how named pipes are used in C# which is a popular needed topic!
I’ve been wanting to do this! Amazing how you’ve already solved this problem. Thank you, love your stuff.
Really easy to understand tutorial and a great topic. Thanks a lot!
This video does a better job of explaining named pipes than the c# documentation. Sigh.
Love your Tutorials
Thanks! I'm glad to hear it!
3:10 The same thing I'm thinking to do as well.
I see tutorials but many times I watch many tutorials to make just one thing or adding something new by my own. I'm thinking to make a tutorial for others and for myself tp document it so when I forget I can watch it exactly as I wanted.
Yup, teaching something is one of the best ways to increase your own knowledge. I've learned a ton by making lots of videos because I need to understand something fully before I can make the video.
@@CodeMonkeyUnity Yep.
Win win for everyone.
Me: *Hacks into mainframe using unity*
Using unity’s particle system
Me: Hack NASA using unity
The thing is - Unity is just a game framework (if you are using it without the Editor) so you could actually do ANYTHING that could be done in CLR including hacking.
Like... it's a stupid idea... but why not? :-)
Hmm, that is pretty interesting. I also thought about local network approach. I'm not sure, but i think there is a way to make this kind of communication between applications with something like mirror library that can be used to create local multiplier. But for that method you probably have to do everything in one unity project. Anyways, great tutorial, just had different idea of doing this
I am very thankful you made this video. I have spent days playing with pipes. I also did not have the 64 bit issue with 2022.3.30f1 so maybe it has been addressed.
Thank you for this video, currently have exactly the same issue XD I also creating my own version of stream avatars for fun
This example seems like quite a niche use case, does anyone have other cases where this could be useful besides a live-streaming type application?
Local servers, maybe
This is just communication between two separate application so the uses are nearly infinite.
Maybe you have your game running and on a separate app you're storing data and displaying some graphs.
Maybe you have a C# app and you want to use Unity to make some cool visualizations.
Maybe you want to make a local multiplayer game and have a second app controlled by another person setting some rules.
Anything that requires communication between two instances can be done with this method.
well i've publish a comment about a game using this "feature", essentially a multiple window game, drag and drop the window to create a level layout, if you find this helpful ^^
Asymmetric gameplay, like you have a platformer game and a godmode secondary window where you place/move the platforms
You can set an IP to sent the message. So it’s possible to develop one “joystick” app to control your pc game from your phone (I guess)
I tried transparent app video(2019 3.3 version 3D) and I have some suggest to people who new to that video.First,It is a 3D project,not URP project as usual.I had checked URP project,however URP project's camera didn't work with no RenderPipeline Asset and its project settings inspector has some different to 3D project.Second, you have to comment out all codes which cause errors,because it is not a URP project.After doing what I suggest,you could set those settings as video teached. Final result will be transparent if you build and run the scene including in the package.
Very nice!
Never heard of it before, but there are so many great ways to use this.
The greatest thing is - that is a .NET feature so you could use it wherever you want to - not just in Unity games :-)
As always, a very useful video !
i think this topic will be very helpful to create a multi window game, for example drag and drop a complete different window to complete a level layout, then the player will be able to move across the multiple windows, interesting topic, Thank You Code Monkey !
That would be a very interesting application of this!
@@CodeMonkeyUnity feel free to experiment with it if you want to, it's just an idea for experimentation and i will surely try it but not for now, so anyone that want to try it out, go for it :)
@@F41nt13 oh yeah you're right, i was more thinking about a game outside the "game", for instance this concept can litterally be applied to multiple screen in-game
I saw your AD on this Video LOL
Very nice video
Thank you! I'm trying to use this technique to get julia and Unity to talk to each other (because I want to build a neural network) fortunately this name up when I searched for 'NamedPipes in Unity'
Took me ages to get it working so I hope the video helps you!
@@CodeMonkeyUnity gave me a starting point. I can get the codes to connect but I can't get the data to read from the stream on the Julia side. (haven't tried or the other way - I want Julia to take input and return output). I've only been at it 1 day though.
I've also never used Julia before, so I'm also learning a brand new language. Kind of on the deep end. I'm intermediate to advanced on the unity side though.
@@CodeMonkeyUnity stunning success. Biggest problem I had it that you have to close the Stream Writer before the data actually gets written. It won't be available to be wread until the Stream Writer closes.
(I didn't use the code you copied - Unity has a StreamWriter and a StreamReader built in)
2:55 This white BG totally killed my eyes. Anyway, Interesting video!
Hi. can i earn money with making hyper casual games for mobile
and how much
are you know?
Sorry, dark mode burns my eyes
@@elman5769 It's hard to answer... Some casual games do make a lot of money. Will YOUR game make a lot of money - we can't predict.
Try it - why not :-)
In that multi application spirit, I would love to see a video about networking. P2P and server/client based. Also should networking be coded first or the game first? Should the game be created with networking in mind or is it easy to switch later on? Some simple 1v1 game prototype would be interesting to see.
Networking is a very tricky subject so if that's essential for your game then it should definitely be something you work on right away. It's extremely difficult to tack on a multiplayer mode months into development.
It was very interesting.
I am thinking of a game in which the player and his character use their cell phone: IRL for the player, in the game for the character.
Instead of using Thread.Abort() you could use a task like :
private static void StartTask()
{
ClockTask = Task.Run(async () =>
{
await MyMethod(cancelTokenSource.Token).ConfigureAwait(false);
}, cancelTokenSource.Token)
.ContinueWith(t =>
{
t.Exception?.Handle(e => true);
MethodToRunAfter();
Console.WriteLine("You have canceled the task");
cancelTokenSource = new CancellationTokenSource();
}, TaskContinuationOptions.OnlyOnCanceled);
}
Good afternoon Mr.Monkey, it would be greatly appreciated if you could make a video on multi-language support. Thanks.
Unity now has an official localization package, I haven't looked much into it but it seems pretty feature rich
This is awesome, thanks for sharing
You really gonna make that Ads as your game?
Okay then, waiting for it to launch! XD
That’s real cool, thanks for sharing it
omg Mr. CM, awesome vid, exactly what I was looking for ... I'm gonna go try to find the code in the utilities ... but truthfully, being a lazy coder (the best kind :) I was hoping this was already available ... and if I don't find ... I will be copying from the video ... I'm gonna need more redbull :)
I copied all the code and added the FunctionUpdater class but I'm pretty sure it's not running ... since it creates it's own global gameObject I'm not sure how to start this ... maybe I need to initially add FunctionUpdater to a gameObject in my main script ... not quite a noob but still struggling :( ... help ?
If you're using the script from my utilities it will auto-initialize itself. It will indeed create a new game object and attach a MonoBehaviour to run the Update code.
Is the object being created in the hierarchy? If so then it should be calling the Action on every Update
Awesome useful video. Thanks
Im not by any means an expert i just tried it twice and kinda failed but you don't always have to make a tcp connection you can just use udp witch is less reliable but much faster
I know this doesn't have anything to do with the video just wanted to direct any future readers to what methods they can use
Yup UDP is yet another possible option
Question: Could you have used the Multi-display feature and have everything in one app ? 1 screen (transparent) to Display 1, 2 window to Display 2
I also attempted that approach but I couldn't get both windows to be transparent at the same time. If the second window was meant to occupy the whole screen then that would work but in my case i needed a small control window so I could also read the normal chat in my browser.
kinda something im looking for but i have to open a new scene into a new window, in runtime and have two scenes in two windows in one display.
Instructions unclear, I hacked into Area 51
Love it!
Hi Code Monkey!! I got my script together, thank you for your videos... is there anyway you could make a video talking about the new input system, and how to convert you're normal script to work with the new input system? I didn't realize there was a new system. I just found out about the unity RP for 2D lighting...
Niceee tut! :0
Where i can see how to make my first game in C# i want learn
I covered C# basics here ua-cam.com/video/IFayQioG71A/v-deo.html
This is awesome
Here's the code that I produced. A request was made to make a background service and a console which communicates with said service, whilst the service is running independently. It looks like the code below:
public class NamedPipeService : INamedPipeService
{
public void StartServer(string pipeName, Action onMessageReceived)
{
// server.WaitForConnection is a blocking operation, so let it run in its own thread.
Task.Run(() =>
{
using (var server = new NamedPipeServerStream(pipeName))
{
// It's fine that this is a blocking operation. If a connection is made, then
// process the incoming data first, and only then accept a new connection.
server.WaitForConnection();
// Connected; Process the incoming information.
using StreamReader reader = new StreamReader(server);
var parametersJson = reader.ReadToEnd();
onMessageReceived(parametersJson);
}
// Data processed, connection closed, we're accepting a new connection again.
StartServer(pipeName, onMessageReceived);
});
}
Huh that’s actually really cool
whoa great video
oosp I actually shut down Unreals data centers, we need more clear instructions manual for this!
Hey man! Can you do a video about how to create a node based dialog system?
@codemonkey: a suggestion: Instead of calling "abort", you could have a status field in your loop condition, that would let run out your thread, if the status field value toggles.
Hi mr code monkey, hope you have a great day. I'm wondering which should i start with, Unity or UE?
People say that unity is a good start, but i'm also at least decent enough at c++ since its my college language haha
Both are excellent engines. for me I use Unity so that's what I would recommend but Unreal is great as well.
What types of games do you want to build? For 2D Unity is the clear winner.
Both engines have free versions so just try them out each for a few weeks and then see what you like about them.
Nice video
idea from @Dane it would be highly appreciated if you could do a video on the topics of multi-language support for games :D
Unity now has an official localization package, I haven't looked much into it but it seems pretty feature rich
@@CodeMonkeyUnity oh didn't know, thanks I'll try that 😄
I am trying to create a communication between .net webAPI and unity inside the server computer through this project.
May I ask a question?
I want to send a request from a web api to unity. So is it right for Unity to be the server? Or is it right for the web api to be the server?
and I want to execute a function in unity when communication is sent from .net to unity, is this possible?
You can make a HTTP requests from Unity ua-cam.com/video/Gk0-amfn5DM/v-deo.html
@@CodeMonkeyUnity Thanks for your reply.
I want to send the current screen of Unity to the outside using a screenshot.
However, to use this method, we need to know when to send the screenshot through the communication between Unity and WebAPI.
The method I have implemented so far is with WebAPI as the server.
When a specific WebAPI call is made, the server is opened.
Unity is already in runtime and reacts to take a screenshot when the server is open.
I knew how to show you with the link. Is it okay if I ask for some help?
How did you implement Arbitrary Code Execution protection?
Why my comments are kept to be removed? I just questioning would it be possible to use SignalR as an alternative option?
I haven't deleted any comments so it must be some automated UA-cam thing.
Also I'm not familiar with that library but it seems to be a socket connection which yes it could work
I think its niche-ety is massively offset by its usefulness to developers.
Hi, can you please make a tutorial on how to make the camera follow your game object like in your ground check video
The simplest way is with Cinemachine ua-cam.com/video/Ml8ptNeezsU/v-deo.html
@@CodeMonkeyUnity Nevermind I programmed one myself by hooking it up to my movement script and having it move when the ball did.
Please kind sir, make game that increases visual memory and hearing memory of the brain. For phone and pc plss. Add somekind of traditional japanese music or chinese. I think it would be cool project. Because in todays schools most kids suffer from their brain low speed memory, and it's hard to remember everything.
Hey Code Monkey, can you make a video on how you make bullets spawn from a gun and go to the center of the screen where the player is pointing at? It’s a weird request so sorry if it’s inappropriate to post it here :’(
You can look into the FPS Microgame and see how they handle that, essentially you need to get the camera rotation and make the bullet spawn from the weapon and slowly over time rotate towards the camera.
I covered it in detail in the FPS game that I made for the course ua-cam.com/video/weN4U6jQ0zs/v-deo.html
I need it.
Can you make videos on 3d games(unity3d).
I just made the Factory game a while ago which is in 3D ua-cam.com/video/88cIVR4KI_Q/v-deo.html
Don't see anything on downloading the source code for this on your site. Could you provide a link?
This one is just a handful of lines so I didn't make the package, all the code is visible in the video.
The title is really misleading. The actual topic is good though. Was confused by the title why you had such a video.
Any idea how i could get my 2. monitor screen into my application? On a plane or a sprite doesn't matter.
Hmm not sure, the transparent window that I made simply makes it transparent, it doesn't actually see what's on screen
@@CodeMonkeyUnity
Sry for the textwall.
Tldr: Can you pleas look around a bit and see if you find something
Do you maybe have tips where i could look or do you maybe know someone who could have an answer?
I tried to find a solution for around 3 week and nothing works.
Windows forms has Code that can get the screen and i got the libaries to work in Unity but Unity doesn't have the permissions or something to read the image.
Then I tried OBS Virtual Webcam because Unity can Read Webcams. With a new registry entry Unity does find the OBS cam but it just shows black. (Unity also shows black if the real webcam is use by another program so i guess unity thinks the OBS cam is in use by OBS...)
The I tried to make an IP stream from OBS to Unity but i also didn't got that to work.
My last idea would be to stream OBS to a unlisten YT stream and open that in a Browser Asset for Unity. But i think that will have a terible latency... And i woulf have to buy a asset for the browser in unity because i have no idea how i would get something like that to work.
Could you pleas look if you can find something.
Ps:
Would also be something cool for a Video because you could do many funny and stupid things with that.
The pc screen in VR
If you want to show a PDF or Powerpoint or what not you could just open it on the monitor instead of inporting it.
You could play a game inside unity like minecraft if you GPU can handle it etc.
POV:you early and want people to command and like your comment 👀
What times do you live stream? Is it random?
Yeah it's pretty random, it's whenever I have some task that could also be done live. I'm working on 2 projects right now that would work so I might make a livestream sometime tomorrow or next week.
@@CodeMonkeyUnity ok thanks
@@CodeMonkeyUnity what kind of projects are you working on right now, if that’s not a secret?)
@@Babenkoalef Working on converting a Action-Adventure game into an RTS and making a House Building System! Should be interesting videos!
What isFunctionUpdater? Yopu kinda just fly by it and i cant find anything online about it
It's one of my classes in my utilities, basically it creates a dummy MonoBehaviour to run some code on every Update. You can download the utilities and inspect the source code
So can I use Unity Pipes instead of constantly Polling my website?? its an indie mmo.
Named Pipes only work on local network, not online.
So for online you can contact your website with a simple HTTP request.
Or for something more complex make a proper server and use a TCP/UDP connection.
It's "System.Pipes" so actually it has ZERO things in common with Unity :-)
Unity was just an example how you could use it.
Hi there. I am not sure what the FunctionUpdater does. I've gathered that it continuously runs the specified function on the main thread - but I dont know what code gets used for that. Can you please elaborate
It creates a new game object, attaches a MonoBehaviour that has an Action running on every Update
You can check out all the source code for the utilities from the website
@@CodeMonkeyUnity ok I found it in the source code. Thank you for replying. What would a normal C# equivalent of the FunctionUpdater look like? In my case the Pipe Client is not a unity application
So did you find the problem of server at 64 bit build?
The problem is the version of Mono that Unity uses does not have that implemented in the 64 bit version, no way to solve it other than asking Mono to implement it in a future version.
@@CodeMonkeyUnity
I see. Thanks!
Hi I haven't got access to my pc right at the moment but I came across this..can it be done
Hey, so I was wondering if you can say using System.Threading; at the top then saying Thread.Sleep(milliseconds) to pause the script for however long you want instead of using a coroutine. Can I do that?
Hmm sure you could use a separate thread whenever you want a timer but that is needlessly complex.
If you use Thread.Sleep(); on the main thread it will lock your game until that time passes, you definitely dont want to do that.
@@CodeMonkeyUnity thanks
Can i make game with smart phone?
Yes but it will be a little bit harder:
* Try Construct 3 game engine
* Or try Godot 3 Web (it's still experimental but it mostly works).
I would recommend to try the second option
It is simpler in c# than it is in c.
C# was created to simplify Windows application development so most things in C# are very straightforward by design.
ah that's something new
First comment after code monkey
*Hacks dani to see karlson upload date*
Ooh I’m early
Oh no
És rei
"Hack" ... come on :/
HI I'm cool
3:02: "Not sure how many people are interested in such a niche topic, so this video is kind of for my own personal use." *Gives video maximally clickbaity title.* :D
Cool coding video, tho. :)
Early gang
I am the 13th comment and relatively early?
Name your videos appropriately to what you are showing so people searching for it can find it. Using click bait titles like this is not very useful in such obscure stuff.
This is a bit clickbaity. If you want to use legitimate "hacking", you could use ReadProcessMemory or WriteProcessMemory. It's what a lot of literal game hacks use to read and write data to a game process. Setting up a named pipe is quite literally used only to allow other applications to connect to your app - an equivalent would be calling "using a mouse and keyboard" hacking when playing an fps...
Hacking does not just mean unauthorized access, that is just one of the many meanings the word has, which is why to avoid confusion the video is titled "hack into YOUR games", this is not about hacking into OTHER games.
@@CodeMonkeyUnity I disagree. That's exactly what hacking means, and more importantly, it's exactly what it implies in this context. I don't think the title is confusing, I think it's wrong. Do I think it's a violation of the Geneva Convention? No. But is it clickbaity? Yes.
I'd also argue that there's nothing wrong with using RPM and WPM to do this. It might even be easier.
@@CodeMonkeyUnity I like your content, but I have to agree to the other persons comment, this title is kinda clickbait / misleading, I was expecting someting very different from this title.
@@hiTocopter What do you think of the term "life hacks"? What do you think about making a quick prototype as "hacking something together quickly"?
I do know hacking can have also have the meaning of unauthorized access which is why I was very intentional with putting the word "YOUR" in the title.
My first title was actually "Hack into Unity!" which could indeed be misconstrued in that way so I changed it.
I don't like clickbait so I always try to come up with a title that is clickable and truthful.
@@CodeMonkeyUnity Just like I didn't get to choose which meaning of the word "mouse" or "keyboard" I used in my original comment, you don't get to choose what you meant by "hack". Context sets the meaning - which you know, because that's why you changed the original title from "hack into unity" - I'm just saying that adding the "your" doesn't change it. The title still implies "hacking a game", which we all know what it means.
You liked a comment that says "Me: Hacks into mainframe using Unity". Even though that's a joke, it's clearly derived from the fact that everyone knows what "hacking" means in the context of a game or computer software.
Listen, this is already a way longer conversation than it needs to be, so I'm going to leave it here. Like your content, keep up the good work, my man!
40th like
Uhm I dont think that title is good for this video it feels very clickbait