- Home /
Connecting an external program to a unity server
Hi,
I need to connect a windows forms app to a unity server to retrieve and display data. (Just a little bit of data) I looked around on the unity forums but this doesn't seem possible with unitys networking. I was trying to include the unity DLL and use the networkview and RPC calls. If this is in any way possible could someone point me in the right direction? If this isn't possible I think I'll use .NET tcpclient and tcplistener, but I don't knoz if unity plays nice with those. Maybe someone here has another suggestion?
Answer by Bunny83 · Aug 01, 2011 at 04:40 PM
You should use "normal" sockets like you already mentioned. The builtin networking is based on Raknet but the version could change in later versions. It's only meant to create connections between Unity applications.
Including the UnityEngine.dll won't help much since it's just a wrapper-dll for the scripting engine. Most of it's functions are directly mapped to the native c++ functions which are part of the Unityplayer (which IS actual the Unity engine).
There should be no problem to start your own tcp sockets along with Unity-networking as long as you use different ports ;)
Answer by Styn · Aug 04, 2011 at 12:30 PM
I ended up writing my own RPC system over .NET TCP, thanks for the answer!
Please, could you send to me your script?. I need to receive data from a C# application and represent it with numbers and plotting in a graph like it's done in the C# and forms applications. I should represent a math graph from a huge vector of pairs of values and additionaly represent the mean of them numerically. I've got to tasks to do and the most important is how to communicate with another computer (PC) for the date receiving apart of the representation graphically and numerically of the data received.
Thanks.
Please stop posting such personal questions as answers (esp. not multiple times)! I've converted your last answer into a comment. Don't ask other people to write code for you. You can ask Styn to share his script but one time should be enough. $$anonymous$$ost people want to make money with their work and won't share it. So you could wait for a response from Styn or do it yourself. Writing basic network communication in C# has nothing to do with Unity in the first place.
Sorry. Excuse me please. I'm really new at program$$anonymous$$g and in particular with C# and networking. For me it's like a new world but in my job we need to do something like this. I need to convert the data from an ECG processor in a plotted graph in real time and display the mean in another window. I have never done anything like this and it's very important for me. But excuse because I think that you are making a great job as a moderator/ad$$anonymous$$istrator. This community and forum/section is fantastic and has helped to me in an incredible way till now. I'm sorry very much.
Answer by simyuan · Mar 07, 2013 at 09:35 PM
Hello! So happy to know you by seeing your post "Connecting an external program to a unity server". In my project, I also need to connect a windows forms app to a unity server to send commond. But I met following problems:
I found that the network function in unity can not work here, so I chose .Net TcpClient/ TcpServer. It worked, but when I loaded another scene, it stoped until I closed unity in task manager of windows. Do you met this situation before?If so, is it means that Using .Net Network function is not a good way for my program?
Then I try to program with Socket. It worked fine when loading new scene. But I found after connecting with server, the windows forms app cannot send massage successfully. The code that receive data in unity was started in a new thread and run in when(true). Is it a right way to wait the data? or Is there any better way to do that?
Please give me some advice if it is convenint. I will give you my code when I am in my work place. Hope to discuss with you about programming in Unity.
I'm looking forward for your reply
Thank you very much!