Does anybody know or is there an examples on how to create a connection (sockets) using javascript in unity3d?
tomcat
Does anybody know or is there an examples on how to create a connection (sockets) using javascript in unity3d?
tomcat
Use import the corresponding assembly (through @import blabla instead of using blabla).
Aside from that its the same for JS as it is for C#, because both use the same core .NET functionality for the socket access.
Always granted you don’t need to use generics or delegates
Ok, I am not a little confused :? . I havent seen any examples of using .Net librarys from Javascript and didnt know its possible. Can you point me to an example?
Sorry, that was an un-intended “not”.
tomcat
Sockets are not part of Unity
They are part of .NET
As such you will need to read the .NET documentations on MSDN / Mono. As mentioned you will NOT find any UnityScript documentation on the topic as UnityScript is a unity only thing so the general .NET documentation does not care about it.
Ok, thanks. That explains why I cant find anything. By the way, I am still not clear how I can call .NET functions from javascript. Is this possible? have you come across any examples?
tomcat
The main thing you need to do is import the right namespace. The available classes are part of the System.Net.Sockets namespace, like System.Net.Sockets.Sockets or System.Net.Sockets.TcpListener
.NET Functions: All you do in JS, any function and object you use from Unity, is a .NET function
So there is nothing that changes
A good starting point is Networking mit C# | Microsoft Learn or its english counterpart.
this content only exist in german
hehe but code is rather easy to read independent of the language (thats why code is unlimited more powerfull than native language, its precise and its native language independent ;))