Search Unity

Do you have any older projects that use UnityScript? If so, you might be interested in our open source UnityScript to C# conversion tool available to download now.

Back in August 2017, we have begun the deprecation process for UnityScript, a JavaScript-like scripting language, and started working on a conversion tool from that language to C#. Shortly after that, we moved the menu option used to create new UnityScript scripts under Legacy.

Since then we’ve collected a lot of feedback and fixed a bunch of issues in the conversion tool. To name a few changes motivated by your feedback:

  • Support for preserving comments from original scripts
  • Introduced an Editor Integration Package to simplify usage
  • Improved support for a number of UnityScript constructs

With Unity 2018.2, we removed the option to create new UnityScript scripts completely. Now we believe that the conversion tool is feature complete and stable enough to help any of you that still have projects using UnityScript.

Before starting the conversion process, we suggest that you make sure your project builds cleanly on Unity 2018.1, all of your tests are passing and you understand the limitations listed here.

We recommend running the conversion tool through the menu Tools/Convert UnityScript to C#. If you need more control over the parameters used during the conversion you can run the conversion through the command line but keep in mind that the extra flexibility comes with extra complexity.

As an example, the video below outlines the process of converting an older version of Angry Bots project. The intent of this is only for demonstration purposes whence we simply commented out any code causing compilation errors when first open the project in 2018.1.

To summarize, the basic process should be something like:

  1. Backup your project
  2. Open project in 2018.1
  3. Accept API Updater offer (if any) and fix remaining errors
  4. Make sure player builds successfully on each target platform
  5. Make sure all related tests are passing (also, run the project on real devices)
  6. Install the latest Editor Integration Package (see here for instructions on how to install asset packages in the Editor).
  7. Clean editor console
  8. Run the conversion tool.
  9. Fix any remaining issues (running related tests)
Note that if your project targets multiple platforms, you may need to repeat step 8 for each target platform by selecting the platform before running the conversion tool, and then manually merge the converted code, wrapping the code with conditional code accordingly.  This is a limitation of the tool. In this case, you’ll probably use a VCS to restore the state of the project after each conversion.

Step 9 may or may not be required (it depends on which APIs your project uses), but in the Angry Bots example, we needed to fix some API usages.

Since the tool is open source, you’re invited to download its source and look around! Please feel free to contribute any fixes/improvements.

If for any reason this tool does not fit your needs you may want to check other converters available on the Asset Store.

Finally, if you need any help with the tool please ask in this forum thread and we’ll do our best to help you.

12 评论

订阅评论

评论被关闭。

  1. Still using Angry Bots as an example in 2019? Wow, that’s amazing. That demo project is almost 10 years old. I built that sh*t to last I guess. Back then demo projects were developed in less than 2 months and had to align with a major release (Unity 3.5 if I remember correctly). We weren’t given even close to enough time to make these things. But somehow they’re still useful today (even if to show a deprecated modality of Unity).

  2. Very nice tool!

  3. You should make the same with Unet u.u and the new network system

  4. Thanks for the link . . .
    . . . What a right time to give a shout out to the site that helped me to convert many of my JS/UnityScripts : m2h.nl/files/js_to_c.php

  5. Thanks for the link . . .
    . . . What a right time to give a shout out to the site that helped me to convert many of my JS scripts : m2h.nl/files/js_to_c.php

  6. Isn’t this a revival of the message you wrote in 2017?
    How many do you think are interested in this and I don’t quite understand who’s controlling Blogs.
    I’ve been quietly reading blogs but it seems like they are all random and it provides very little values.

    I guess you don’t have any good posts worth sharing or just saving good ones for the next United keynotes??

    Seriously, I’m sorry but I don’t really care about unity sponsored random event or your employees. You can perhaps post them on your internal website. It seems like the most of the blog posts are just tidbits and you are posting it for the sake of updating pages once in a while and it has no or very little values.

    I think the only blog post that was worth reading it was, explaining the difference between LWRP, HDRP and Standard lighting models. It was a very good read and I learned a lot reading it and understood where Unity is going.
    It also made into the official documentation and I can easily find it and read it again when I want.
    It is really a good example of quality blogs and you can kill two birds with one stone by improving much-needed documentation updates at the same time.

    If someone landed on this blog page by accident, I bet they have no idea what business this company is in.

    I recommend you write more blog that are helpful for the developers. If you want to keep writing the blogs this way, please keep them separated to different pages at least so that I can filter them out.

    Well, more posts are better than no posts, but what I really want to see is posts that are worth reading, such as, new info, what everyone is waiting, some updates on the things that you promised, learning materials and so on.

    Thanks.

    1. Given that Unity 2018.3 was released recently and the support for unityscript was finally removed completely I would say the blog post may interest some people for sure regardless if its partly or fully a rehash of an older post.

    2. Hi Chris!

      Thank you for your readership and feedback. We appreciate both!

      Yes, we made our announcement of the depreciation of UnityScript in our 2017 blog. The goal of today’s blog was to help any member of our community that needed this new tool to bring their UnityScript project into our most recent releases. While this might not apply to all projects, we wouldn’t want to leave anyone behind.

      We strive to execute blogs that are helpful to all of the corners of our community. We hear that you’re hoping for more blogs that are helpful for developers like yourself and will work toward that in 2019.

    3. Blogs are for community engagement, which happens to include, but is not exclusive to, the specific educational topics you enjoy.

      FWIW, those are my preferred topics as well, and I’d like it if they added a “tag” system as well as the top level category filters so I can easily find old content I may have missed or want to revisit.

    4. As a forum moderator I can assure you that this blog is very, very useful, today. I see posts from people asking for help on converting from Unity script on a weekly basis.

      A refresh or reminder could not be more timely, especially in light of the improvements made since. I recommend you put yourself in other people’s shoes, does that sound like a fair recommendation?

    5. I disagree that this post is not useful, its useful to anyone who uses unityscript currently. Just because you read the original post, does not mean everyone has or that everyone even knows its there.

      But I do agree that posts about unity staff members are not useful at all to anyone and while probably a nice motivational tool for the staff members, basically feels like a spam post whenever they are up. I come here to read interesting blog posts, not stuff that should really be internal. Knowing you have a new starter does not really help us in any way and feels like a wasted blog post honestly, when given all the other things you could write about (both technical and non technical)

    6. While I think that the Unity Blog is awesome, and the Unity Blog team does a great job, there are elements of your comment I agree with. I’d like the blog to kill more birds with a stone. Basically, focus on upcoming features that don’t have enough explanation or documentation yet, and create a resource for people who want to be the best and brightest at using Unity’s latest releases.

      The blogs’ wording could be referenced in the site’s actual documentation, cutting down on copy writing time, making sure you guys’ work gets utilized and appreciated in even more places, and even allow you to steal the documentation team from time to time and get even more blog posts out per week. I’d love to see a blog post a day!

      You guys are awesome, thanks for making this blog! It’s one of my favorite blogs on the internet.