Switch from .js to c#

Hello, I want to transfer my project from .js scripts to c#. I found a website like this…

http://files.m2h.nl//js_to_c.php

does it work? simple “translate” the language and everything runs like on .js? Thank you!

@Devision4,

Unfortunately, there’s no way for us to tel you whether the site you listed works or not, because we don’t have access to anything they’re doing behind the scenes. However, if it were me, I would not trust a random site I found on the internet to run any kind of scripts.

There are ways to translate between JS and C#, and I’ve collected a couple of them in a post here: http://fragileearthstudios.com/2011/10/18/unity-converting-between-c-and-javascript-2/

If those don’t work for you and you find another good resource, please let me know so I can add it to that list.

You’re in luck because UnityScript to C# is actually very easy :wink:

This solution will not work for coroutines because they are very special and can’t be decompiled that easily. Most other things will work pretty well.

  • First download ILSpy if you don’t have it already.
  • Create a Standalone build of your project.
  • Take a look into the folder _Data/Managed/
  • Locate the files “Assembly-UnityScript.dll” and “Assembly-UnityScript-firstpass.dll” (maybe you only have one of them).
  • Open ILSpy and drag the two files into the tree on the left side.
  • Select C# as decompiling language at the top
  • View the classes you want to “convert”, select the text and copy it in a scriptfile.

Now you have the same classes in C#. There are a lot unnecessary things that the UnityScript compiler has generated, but it won’t hurt. Since you have the scripts as C# you can do some manual optimisations ;).