Search Unity

  1. The 2022.1 beta is now available for testing. To find out what's new, have a look at our 2022.1 beta blog post.
    Dismiss Notice

I have some confusion about the c# and js

Discussion in 'Scripting' started by wuesugi, Aug 23, 2011.

  1. wuesugi

    wuesugi

    Joined:
    Mar 31, 2011
    Posts:
    6
    I don't know if the js can make a socket communication with the server.But i used c# to do it, and it works. What i am confuse about is I cant find any socket api in js documentation .Does it means that c# can do something that js can't.So the next problem is how to get all the function by scripting.Do I have to use both language to achieve it.
     
  2. bdev

    bdev

    Joined:
    Jan 4, 2011
    Posts:
    656
    I don't know alot of JS but i think that you can do almost anything in JS as you can in C#, except for extension methods. You shuold be able to import the .net namespace you need. If you do need to use both languages, you could write a wrapper in C# and slip it into a folder named standard assets, or plugins to get it to compile prior and available in js and boo as well.

    Sorry i cant really go into js stuff as i don't know it as well, but i think all things .net are accessable from it.
    http://msdn.microsoft.com/en-us/library/sb27wehh.aspx

    try seeing if you can't use those classes in that namespace in JS. I think the only limitations come in when you talk about web builds where some classes in .net are disabled for security.

    Its unlikely to find documentation specifically for JS on them because its not a supported language by microsoft (no support for J# anymore) but you should be able to still use them as you would in C# but in JS.. Thats one of the downsides to using boo or JS/UnityScript. Unless your pinned or absolutely love JS and don't want to go back to C# i'd suggest to as it might be a bit easier in this case.
     
    Last edited: Aug 23, 2011
  3. wuesugi

    wuesugi

    Joined:
    Mar 31, 2011
    Posts:
    6
    thanks for telling, i will try to import the namespace to find out if js can use socket as well ,If it work i think use only one language would be better
     
unityunity