Search Unity

UnityScript 2 CSharp conversion tool

Discussion in 'Experimental Scripting Previews' started by AdrianoVerona_Unity, Aug 11, 2017.

  1. Ostwind

    Ostwind

    Joined:
    Mar 22, 2011
    Posts:
    2,773
    I don't think it's that simple. Such checkbox would mean boo and unity script would still remain all around the code base and create extra work from time to time when code gets refactored and improved. You cant just completely ignore the old code and leave it unsupported if it's using the core features from the engine.

    Let it die.
     
    orb likes this.
  2. protopop

    protopop

    Joined:
    May 19, 2009
    Posts:
    1,065
    I agree with you, but I don't think they'll do this. Many people see C# as superior, but I prefer the simpler syntax and artistic flexibility of UnityScript. Plus it was a big reason so many of us web and Flash designer made the jump to Unity in the first place. There was very little barrier for us to use Unity. Now new Javascripters will have to learn a new language if they want to use the software. Javascript might seem messy to many coders, but as an artist who likes to iterate quickly, i find Javascript to be less rigid. To me that's it's charm, and we will be losing that in this transition. Anyways Javascript and WebGL are only becoming more popular, and I am seeing people experiment more with them. Just as with Flash giving way to HTML5, maybe in 5 years there will be an open source game engine based on Javascript and WebGL - talk about open standards:)
     
    funkyboy likes this.
  3. Tanaalethan

    Tanaalethan

    Joined:
    Sep 3, 2014
    Posts:
    17
    I personally use strictly Unityscript. It was what originally brought me over to Unity when I was comparing engines (Unreal, Unity, etc). For me, C# is clunky and ugly and extremely verbose.

    Example of what I mean:
    JS
    Code (csharp):
    1. function MoveMeRight(){
    2.   transform.position.x+=1;
    3. }
    C#
    Code (csharp):
    1. using UnityEngine;
    2. public class MoveMe: MonoBehaviour {
    3.    void MoveMeRight() {
    4.       transform.position = transform.position+Vector3(1,0,0);
    5.    }
    6. }
    It's just a lot more to write to do the same exact thing.
    Let alone the complete lack of dynamic arrays
    JS
    Code (csharp):
    1. var a = new Array();
    2.  
    3. function AddRow(s){
    4.    a.Push(s);
    5. }
    C#
    Code (csharp):
    1. using System;
    2. using System.Collections;
    3. using System.Collections.Generic;
    4. using UnityEngine;
    5. public class Example : MonoBehaviour {
    6.    
    7.    public String[] a;
    8.    
    9.    void AddRow(String s){
    10.        String[] b = a;
    11.        a = new String[a.Length+1];
    12.        int i = 0;
    13.        foreach(String d in b){
    14.            a[i] = d;
    15.            i++;
    16.        }
    17.        a[a.Length-1] = s;
    18.    }
    19.  
    20. }

    Also I tried using your "auto converter", and I just get this error:
    Using the package version available https://github.com/Unity-Technologies/unityscript2csharp/releases/tag/v1.0.6502.12705


    You keep saying you want to keep Unity appealing to artists and non-programmer types, but Unityscript is the ENTIRETY of your draw in that department. You also keep saying you have something "in the works" that will keep that focus. So here's my suggestion. Instead of dropping support for your most user friendly aspect and draw for the non-programmers before you have any form of replacement, you keep it in until your new replacement has a foothold.
    I understand the wish to move to .net 4.6, however you said in your own post its just a matter of updating the unityscript compiler to support it and it would "cost time and money" to do so. What do you think you're telling your customers do to? Instead of telling your dev team to spend a couple months converting one tool, you're telling your thousands of customers to convert their entire projects to an entirely different language costing your CUSTOMERS hundreds of thousands of dollars (combined) and months of development time, potentially halting the progress of their entire projects.
    It's a horrible dick move, and a real turn off for new AND veteran users of your software.
     
    neoshaman and protopop like this.
  4. nat42

    nat42

    Joined:
    Jun 10, 2017
    Posts:
    354
    As someone new to Unity myself, I'd say that's not C#'s fault, that's Unity's implementation, but your right the latter looks gross (and by that I mean just the transform line, the rest is you not being fair, c# lets you have functions outside of classes(edit: what was I thinking), and pre-ES6 classes are syntactically uglier)

    I think this is misguided, Javascript gives you a dynamic list-y thing and calls it and array, while C# gives you a bunch of data structures and lets you choose the most appropriate for your needs.

    Ultimately when I ask C# for an array I want a contigous block of memory, fast to access slow to resize. If I want something growable I use a list (or a stack or...)
    TLDR: if you want something like Javscript's array use a List
     
    Last edited: Nov 16, 2017
  5. protopop

    protopop

    Joined:
    May 19, 2009
    Posts:
    1,065
    This is a perfect example:) And well said - i feel like the unity environment has gotten a lot less artist friendly with this move. It's great for programmers, but it's also part of the reason many of us left Flash when they introduced the much more verbose ActionScript 3.
     
  6. AdrianoVerona_Unity

    AdrianoVerona_Unity

    Unity Technologies

    Joined:
    Apr 11, 2013
    Posts:
    231
    Which version of Unity are you using? I think this type (CompilationPipeline) is only available in 2017.3. I'll double check and add code to warn users if the version they are using does not support that.

    Best
     
  7. Tanaalethan

    Tanaalethan

    Joined:
    Sep 3, 2014
    Posts:
    17
    2017.1 gives "compilation" error, and 2017.2 gives "compilationpipeline" error.
     
  8. Tanaalethan

    Tanaalethan

    Joined:
    Sep 3, 2014
    Posts:
    17
    I was pointing out the fact that a comparable equivilent doesn't exist on C#. Lists are close, but still just not as simple. In JS, it's much easier to just make an array, push a bunch of data into it, then create/resize a natural array and drop the data in, rather than create an array, dulicate that array, add the new row, merge the arrays, rinse repeat for all however many items you have.

    The biggest losses here are the simplicity for newer users and the amount of projects that just now became completely defunct and are requiring developers to spend months converting projects and reassigning variables, recreating/fixing prefabs, reassigning script mismatches, etc.
     
    protopop likes this.
  9. r618

    r618

    Joined:
    Jan 19, 2009
    Posts:
    795
    ugh, are you aware of
    Code (CSharp):
    1. Array.Copy
    ? Or Linq, for that matter ?:

    Code (CSharp):
    1. void AddRow(string s)
    2. {
    3.   a = a.ToList().Add(s).ToArray();
    4. }
    No ? I recommend to become more familiar with them.
     
    Last edited: Nov 16, 2017
  10. Tanaalethan

    Tanaalethan

    Joined:
    Sep 3, 2014
    Posts:
    17
    No I'm not. and I can safely say most other people in my position aren't either. And seeing as when putting together those examples I went back thru the documentation to double check my assumptions and didn't find them, otherwise I wouldn't have made those examples. So my examples still stand. And your code is still a good example of the verboseness of C# over JS. There's just so much extra stuff to type to do the exact same thing, and to someone like me (and apparently others) this is horrid and ugly. Why would I do 3, 4, 5, or 20x the typing to do stuff I can do much simpler, much easier, and to be honest, with much better documentation.


    As for the converter itself, I installed 2017.3 just to test this, and it doesn't seem to do anything.
    A relatively new project (only a few days old), copied it to a new folder, imported the package with the integrated tool, and it seems to "run" but do nothing. There's 8 js scripts in there, and not a single one is touched. All the assigned scripts to gameobjects are still assigned to the js files, and I don't see any new files. Something seems broken.
     
    Last edited: Nov 16, 2017
    protopop likes this.
  11. AdrianoVerona_Unity

    AdrianoVerona_Unity

    Unity Technologies

    Joined:
    Apr 11, 2013
    Posts:
    231
    Hum.. you should see a dialog explaining what to do next. Basically you should have an extra menu entry (Tools/Convert Project from UnityScript to C#)

    Anyway, I'll investigate it later today

    Thanks for your help so far.
     
  12. Tanaalethan

    Tanaalethan

    Joined:
    Sep 3, 2014
    Posts:
    17
    I get the menu, and when clicking on it I get the dialog asking what I want to do.
    I click accept yes I did make a backup, (copied project folder, converted it to 17.3, etc) and it brings up a new window "converting project to C#" with a progress bar.
    Said progress bar takes a couple seconds then closes with "Project successfully converted to C# you may now delete this folder"
    Code (csharp):
    1.  
    2. UnityScript2CSharp converter finished (You can remove 'UnityScript2CSharp' if you dont plan to run the converter in ths project again).
    3.  
    4. Converting 'Runtime' (9 scripts)
    5. Conversion aborted due to compilation errors:
    6.  
    7.    C:\Projects\Lomma\Lomma T1cs\Assets\Scripts\buildingBase.js(2,8): BCE0021: Namespace 'UnityEngine.UI' not found, maybe you forgot to add an assembly reference?
    8.  
    9.    C:\Projects\Lomma\Lomma T1cs\Assets\Scripts\unitBase.js(2,8): BCE0021: Namespace 'UnityEngine.UI' not found, maybe you forgot to add an assembly reference?
    10.  
    11.    C:\Projects\Lomma\Lomma T1cs\Assets\Scripts\buildingBase.js(7,20): BCE0018: The name 'Image' does not denote a valid type ('not found'). Did you mean 'UnityEngine.Experimental.UIElements.Image'?
    12.  
    13.    C:\Projects\Lomma\Lomma T1cs\Assets\Scripts\gameHandler.js(13,20): BCE0018: The name 'Text' does not denote a valid type ('not found'). Did you mean 'UnityEngine.WSA.Toast'?
    14.  
    15.    C:\Projects\Lomma\Lomma T1cs\Assets\Scripts\gameHandler.js(29,23): BCE0018: The name 'RawImage' does not denote a valid type ('not found'). Did you mean 'UnityEngine.SocialPlatforms.Range'?
    16.  
    17.    C:\Projects\Lomma\Lomma T1cs\Assets\Scripts\gameHandler.js(31,24): BCE0018: The name 'Text' does not denote a valid type ('not found'). Did you mean 'UnityEngine.WSA.Toast'?
    18.  
    19.    C:\Projects\Lomma\Lomma T1cs\Assets\Scripts\gameHandler.js(32,27): BCE0018: The name 'Text' does not denote a valid type ('not found'). Did you mean 'UnityEngine.WSA.Toast'?
    20.  
    21.    C:\Projects\Lomma\Lomma T1cs\Assets\Scripts\gameHandler.js(33,23): BCE0018: The name 'Text' does not denote a valid type ('not found'). Did you mean 'UnityEngine.WSA.Toast'?
    22.  
    23.    C:\Projects\Lomma\Lomma T1cs\Assets\Scripts\gameHandler.js(34,26): BCE0018: The name 'Text' does not denote a valid type ('not found'). Did you mean 'UnityEngine.WSA.Toast'?
    24.  
    25.    C:\Projects\Lomma\Lomma T1cs\Assets\Scripts\gameHandler.js(35,27): BCE0018: The name 'Text' does not denote a valid type ('not found'). Did you mean 'UnityEngine.WSA.Toast'?
    26.  
    27.    C:\Projects\Lomma\Lomma T1cs\Assets\Scripts\gameHandler.js(36,30): BCE0018: The name 'Text' does not denote a valid type ('not found'). Did you mean 'UnityEngine.WSA.Toast'?
    28.  
    29.    C:\Projects\Lomma\Lomma T1cs\Assets\Scripts\gameHandler.js(37,24): BCE0018: The name 'Text' does not denote a valid type ('not found'). Did you mean 'UnityEngine.WSA.Toast'?
    30.  
    31.    C:\Projects\Lomma\Lomma T1cs\Assets\Scripts\gameHandler.js(38,27): BCE0018: The name 'Text' does not denote a valid type ('not found'). Did you mean 'UnityEngine.WSA.Toast'?
    32.  
    33.    C:\Projects\Lomma\Lomma T1cs\Assets\Scripts\gameHandler.js(39,29): BCE0018: The name 'Text' does not denote a valid type ('not found'). Did you mean 'UnityEngine.WSA.Toast'?
    34.  
    35.  
     
  13. r618

    r618

    Joined:
    Jan 19, 2009
    Posts:
    795
    unity documentation (still) is the same for both - you're nitpicking here, even so with those horrid multipliers of amount of c# code needed to express the same thing as in unityscript - not to mention that 'horrid and ugly' is rather aesthetic than technical attribute ( and to a large degree matter of habit )
    As for learning c# - unity is not a good source - try some c# tutorial, unity can use (finally) some latest versions of .net
    I understand your frustration, but it's really the only way forward.
     
  14. AdrianoVerona_Unity

    AdrianoVerona_Unity

    Unity Technologies

    Joined:
    Apr 11, 2013
    Posts:
    231
    It looks like the converter is not getting the right assembly references.

    Can you run it again and post your Editor.log & the contents of the reponse file ? (you can find the path to the response file in the editor log, in a like like:

    --responseFile "path-to-your-response-file"

    Best

    Adriano
     
  15. Tanaalethan

    Tanaalethan

    Joined:
    Sep 3, 2014
    Posts:
    17
    The files you requested, as well as the obligatory dxdiag when attempting to find what goes horribly horribly wrong.
     

    Attached Files:

  16. AdrianoVerona_Unity

    AdrianoVerona_Unity

    Unity Technologies

    Joined:
    Apr 11, 2013
    Posts:
    231
    Hi @Tanaalethan

    I am afraid the response file is not the correct one (it looks like the one you sent me is the one from the boo compiler)

    I need the one specified in the line

    UnityScript2CSharp.exe --responseFile "C:\Users\xxxxx\AppData\Local\Temp\tmp4706ef13.tmp" -p "project_path" -u "C:/Program Files/Unity 2017.3.0b9/Editor" --outputFile "path to log"

    Best
     
  17. Tanaalethan

    Tanaalethan

    Joined:
    Sep 3, 2014
    Posts:
    17
    Here, just have all of them since there's like 4 of them that say CSharp, not sure which one you want.
     

    Attached Files:

  18. AdrianoVerona_Unity

    AdrianoVerona_Unity

    Unity Technologies

    Joined:
    Apr 11, 2013
    Posts:
    231
    None of them :(

    You need to find (in Editor.log) the line that executes the converter (UnityScript2CSharp.exe). In that line you are going to see an argument --responseFile followed by a file path. It is the content of that file that I want to check.

    For example, if you find the following line in the Editor.log:

    UnityScript2CSharp.exe --responseFile "C:\Users\xxxxx\AppData\Local\Temp\tmp4706ef13.tmp" -p "project_path" -u "C:/Program Files/Unity 2017.3.0b9/Editor" --outputFile "path to log"

    Then you need to provide me the file C:\Users\xxxxx\AppData\Local\Temp\tmp4706ef13.tmp

    Best

    Adriano
     
  19. Tanaalethan

    Tanaalethan

    Joined:
    Sep 3, 2014
    Posts:
    17
    My bad, my misunderstanding. Got off a 14 hour shift at work and did that before face-pillowing. Lets try again.
    Code (csharp):
    1. --------- UnityScript2CSharp Arguments
    2.  
    3. C:\Users\Tanaalethan\AppData\Local\Temp\Unity3D/UnityScript2CSharp\UnityScript2CSharp.exe --responseFile "C:\Users\Tanaalethan\AppData\Local\Temp\tmp7e0d45a2.tmp" -p "C:/Projects/Lomma/Lomma T1cs" -u "C:/Program Files/Unity 2017.3.0b9/Editor" --outputFile "C:\Users\Tanaalethan\AppData\Local\Temp\US2CS_Lomma T1.log"
     

    Attached Files:

  20. AdrianoVerona_Unity

    AdrianoVerona_Unity

    Unity Technologies

    Joined:
    Apr 11, 2013
    Posts:
    231
    Thanks @Tanaalethan

    I've updated the Unity Package with some fixes / improvements.

    Please, download it here and give it another try.

    Best
     
  21. Tanaalethan

    Tanaalethan

    Joined:
    Sep 3, 2014
    Posts:
    17
    Alright.. That worked... Mostly. (Yes I did click the Verbose logging)

    It actually converted the scripts, but... Broke a few things. Most of it seems to work, but it failed recognize recasts from enum to int
    from enum
    Code (csharp):
    1. (gs.cs)
    2. public enum eFaction
    3. {
    4.     Humanoid = 0,
    5.     Beast = 1,
    6.     Demon = 2,
    7.     Undead = 3
    8. }
    Code (csharp):
    1. (gameHandler.cs)
    2. public eFaction thisCompPlayer;
    3. ...
    4. this.ui_Resource_Gold.text = this.PlayerHandler[this.thisCompPlayer].Gold.ToString();
    And it decided to put "this." in front of EVERY variable. like... EVERY VARIABLE.........


    It did properly assert the C# script onto my game objects properly and kept their associations and values, so that's a plus. But even this small project I'm testing it on is already going to add a significant amount of time fixing what the converter broke.
    I have 10 errors so far just from failed catching of recasting enums to ints. Not hard to fix, just annoying.

    also, heading off to work again. I haven't closed Unity yet just incase you need loggig from it that might be lost in temp folders or closing the app.
     
    Last edited: Nov 18, 2017
    AdrianoVerona_Unity likes this.
  22. AdrianoVerona_Unity

    AdrianoVerona_Unity

    Unity Technologies

    Joined:
    Apr 11, 2013
    Posts:
    231
    Hi

    Happy it worked (at least as you said, mostly)

    As for the raised issues:

    1. enums -> int conversions: We are aware of some cases in which the cast is missing. I'll check if this case is one of them and see if it is possible to improve the code to inject the cast automatically. What is the type of PlayerHandler ?

    2. Qualifying member references with this: we are playing it safe. UnityScript compiler is telling us that it is a member access on this and there's no easy way to tell whether this qualification is not required.
    Keep in mind that the converter will never be able to convert some UnityScript sources with 100% of accuracy. The goal of the converter is to do the bulk of the work, but we are willing to keep improving it in reasonable cases. Also, the converter is open source and we are more than happy to get contributions.

    Best
     
  23. Tanaalethan

    Tanaalethan

    Joined:
    Sep 3, 2014
    Posts:
    17
    PlayerHandler is just an object array of each individual playerBase script to reference the player slots
    Code (javascript):
    1. //js works fine
    2. enum eFaction {
    3.    Humanoid,
    4.    Beast,
    5.    Demon,
    6.    Undead
    7. }
    8. var thisCompPlayer : eFaction;
    9. var PlayerHandler : playerBase[];
    10. function Update () {
    11. ui_Resource_Gold.text = PlayerHandler[thisCompPlayer].Gold.ToString();
    12. }
    Code (csharp):
    1. //cs converted broken
    2. public enum eFaction {
    3.     Humanoid = 0,
    4.     Beast = 1,
    5.     Demon = 2,
    6.     Undead = 3
    7. }
    8. public eFaction thisCompPlayer;
    9. public playerBase[] PlayerHandler;
    10. public virtual void Update() {
    11. this.ui_Resource_Gold.text = this.PlayerHandler[this.thisCompPlayer].Gold.ToString();
    12.     }
    Essentially, playerBase handles all that player slots resources and upkeep and stuff, then the script here goes "which player are we? 0? alright, pull the resources of player 0 and update the UI"

    I realize this. It's just a matter of opening all the files in N++ and pressing CTRL+H, replace all in open files "this." with "" and click OK. Cleans it right up, and you have maybe 3 errors to fix that really actually needed the "this." in there at all because C# is kinda dumb at times with knowing you didn't want a random gameobject, you wanted THIS gameobject.
     
  24. AdrianoVerona_Unity

    AdrianoVerona_Unity

    Unity Technologies

    Joined:
    Apr 11, 2013
    Posts:
    231
    Just want to let you know that I've released a new version of the converter (both standalone / unity package) with this bug fixed.

    If you have a chance to try it out let me know if it worked.

    Best

    Adriano
     
  25. Tanaalethan

    Tanaalethan

    Joined:
    Sep 3, 2014
    Posts:
    17
    Project converted (again), zero errors. It did fail to assign two scripts to an object, but that's not hard to fix. Just drag them back on
     
    AdrianoVerona_Unity likes this.
  26. AdrianoVerona_Unity

    AdrianoVerona_Unity

    Unity Technologies

    Joined:
    Apr 11, 2013
    Posts:
    231
    Thanks for the feedback.

    I'd love to understand why they failed. Can you do me a huge favor? Try to convert again, and then send me the files:

    • SCRIPT_NAME.meta.js.old
    • SCRIPT_NAME.meta
    for the scripts that are causing your project to loose references ?

    Also, if you can share your project Unity it would be easier for me to debug and try to fix this.

    Best

    Adriano
     
  27. neoshaman

    neoshaman

    Joined:
    Feb 11, 2011
    Posts:
    4,228
    But then javascript will take a webassembly in the knee (something will be build on top of it and replace javascript).
     
    protopop likes this.
  28. protopop

    protopop

    Joined:
    May 19, 2009
    Posts:
    1,065
    You might be right - i say it'll be visual coding:) I like that you think further into the future.
     
    neoshaman likes this.
  29. petey

    petey

    Joined:
    May 20, 2009
    Posts:
    1,276
    Hey what’s with the Unity package? Does this run from the project now?
    Thanks
    Pete
     
  30. AdrianoVerona_Unity

    AdrianoVerona_Unity

    Unity Technologies

    Joined:
    Apr 11, 2013
    Posts:
    231
    @petey The Unity Package is simple a convenience for users that prefer to not use the command line tool directly. Basically once you import this package you'll get a new menu item (under Tools/Convert Project from UnityScript to C#) that you can select to run the converter (the command line tool).

    Keep in mind that by running the converter through this method we are taking a lot of defaults.

    Best

    Adriano
     
    petey likes this.
  31. Tanaalethan

    Tanaalethan

    Joined:
    Sep 3, 2014
    Posts:
    17
    Scratch that, it was actually an issue on my end. It was an old game object that I deleted a couple test scripts but never deleted the object. Usually it removes them from the object when you delete the scripts but this time apparently didn't. All's good.
     
    AdrianoVerona_Unity likes this.
  32. petey

    petey

    Joined:
    May 20, 2009
    Posts:
    1,276
    Thanks Adriano, I just installed it and I got the same error someone else had with the unitypackage.
    I'm on OSX sierra with Unity 5.6.2p2 using what I think is the most recent version of the tool.

    I was having a little trouble running the tool outside of Unity, could you maybe give an example of a really basic conversion setup on OSX?
    I tried running it from terminal but I'm not familiar with that and I feel I was doing something wrong there.
     
  33. Tanaalethan

    Tanaalethan

    Joined:
    Sep 3, 2014
    Posts:
    17
    That's an exceptionally old version of unity.. The in-editor version only works with the newest Beta build of unity (2017.3), doesn't even work with the newest stable build (2017.2), and the one you're using is 5.6.2 which is .. 6 versions behind stable, so 7 versions behind beta? You should probably update at least to stable, if nothing else than for the new features
     
    AdrianoVerona_Unity likes this.
  34. AdrianoVerona_Unity

    AdrianoVerona_Unity

    Unity Technologies

    Joined:
    Apr 11, 2013
    Posts:
    231
    Hi @petey

    As @Tanaalethan pointed out, the UnityPackage requires a pretty recent Unity to work. I've tested it with 2017.3 (newest beta should work)

    As for you having issues, the basic usage is as follow:

    This is the minimum set of arguments you can try.

    Depending on your project, this may or may not work.

    Basically you can also pass the following command line arguments:

    --unityPath path (to specify the Unity installation path) (I do recommend you passing this, otherwise we'll try to find a Unity installation, but we may find an older version, which may cause issues to the converter)

    --references Assembly references required by the scripts (space separated list). (If your project uses assemblies - for instance from Asset Store products), you'll need to pass the path of the assemblies through this argument

    --gameassemblies : if your project contains Editor extensions this may be required. I also recommend you to always pass this.

    –symbols A (comma separated) list of custom symbols to be defined. : if your project contains code inside #if FOO this code will not be converted unless you pass the symbol (FOO in this example) through this argument

    -i Ignore compilation errors. This allows the conversion process to continue instead of aborting: If the updater complains about Compilation Errors you may try to invoke it passing this argument which just signals to the updater to ignore such errors and try to do the conversion.

    (notice that I've put each command line argument in a separate line, just to make it easier to see. You'll need to pass then in a single line, separating each argument with an space

    This is how it would look like:
    What exact kind of problems are you hitting? Can you give more details?
     
  35. petey

    petey

    Joined:
    May 20, 2009
    Posts:
    1,276
    Thanks @Vagaus that’s great!
    Yeah I know 5.6 is a bit old now, but a solid version :p and I have to stick with it ‘till the end of the project unfortunately.
     
  36. petey

    petey

    Joined:
    May 20, 2009
    Posts:
    1,276
    Hi there,
    Just got the tool running, I thought I'd let you know of what I came across.
    Firstly the exe was really buried in the download (I hope I got the right one)


    I had a few issues with this type of thing -
    Code (JavaScript):
    1. var TempMin : String =  N["main"]["temp_min"].Value;  
    var TempMin : String = N["main"]["temp_min"].Value;
    .js(59,43)Cannot convert 'String' to 'int'.

    Also it had a little trouble with plugins.
    The name 'TextMeshPro' does not denote a valid type ('not found'). Did you mean 'UnityEngine.TextAnchor'?
    I had this in references as --references TextMeshPro is that right?

    Thanks!
    P.
     
  37. AdrianoVerona_Unity

    AdrianoVerona_Unity

    Unity Technologies

    Joined:
    Apr 11, 2013
    Posts:
    231
    Hi

    Yeah, that is the executable meant to be used by the UnityPackage. You can get the same thing directly in the github reelease (there's a zip with the executable there)

    What is the type of N. My bet is that you are hitting one of the converter limitations, which is the conversion of UnityScript.Lang.Array to a simple array. If this is the case, the easiest way to fix is to change the converted code to use a Dictionary<string, Dictionary<string, string>> (at least that's what it looks like to me based on the single line you posted ;) instead of the simple array.

    If you are passing --reference TextMeshPro as an argument to the converter, no, this is not correct. You need to find (on your disk) the TextMeshPro assembly (.dll file) and pass the full path of that file in the --references.

    Maybe, an easier way for you to get the right command line arguments would be to install the latest Unity beta (can be on a Virtual Machine or a separate machine), open (a backup of) you project on this version of Unity and then, after importing the converter package, run the converter through the Tools menu.

    After the converter finishes you can see (in the Editor log_ the exact command line we used (you'll need to adapt the path to your Unity installation though)

    Best

    Adriano
     
  38. Tanaalethan

    Tanaalethan

    Joined:
    Sep 3, 2014
    Posts:
    17
    Copy project to new folder (backup)
    Install and open 2017.3 Beta and open the project (let it reimport)
    Import the US2CS package
    Convert project
    Save & Close
    Open project in 2017.2 Stable (again it reimports)
    Continue working on stable platform just with converted scripts and gameobjects
     
  39. Tiberius1701

    Tiberius1701

    Joined:
    Sep 16, 2014
    Posts:
    53
    Hi -

    I tried the automatic converter, but none of my files were converted. Using 2017.3.0f1, I brought my project in with 0 errors, and then brought in the US2CS project.

    But there are errors reported in the log after running.

    Some of these are:

    The line
    var Text_Objective : UI.Text;
    gives the error "The name 'UI.Text' does not denote a valid type ('not found')."

    The line
    var Image_Logo : UI.Image;
    gives the error "The name 'UI.Image' does not denote a valid type ('not found')."

    The line
    private var eventSystem : EventSystems.EventSystem;
    gives the error "The name 'EventSystems.EventSystem' does not denote a valid type ('not found')."

    The line
    var MGR_Analytics : analyticsC; //references a script analytics.cs
    gives the error "The name 'analyticsC' does not denote a valid type ('not found')."

    The line
    instructBG.GetComponent(UI.CanvasScaler).referenceResolution.x = width;
    gives the error "BCE0005: Unknown identifier: 'UI'."

    These aren't all the errors, but a cross sample of some of the repeated ones.

    Again, the game compiles and runs with these lines of code and works as it as it should, but they got caught in the autoconverter.

    Any help would be greatly appreciated.

    Kindest Regards,
    Garry
     
  40. AdrianoVerona_Unity

    AdrianoVerona_Unity

    Unity Technologies

    Joined:
    Apr 11, 2013
    Posts:
    231
    Hi @Tiberius1701

    This looks to point to a bug in the converter.

    Can you share your Editor.log file?

    Also, if possible can you share (privately) your project? Or try to reproduce the same error with a small sample project ?

    Best

    Adriano
     
  41. Tiberius1701

    Tiberius1701

    Joined:
    Sep 16, 2014
    Posts:
    53
    Hi Adriano -

    I have started a private conversation with you - please let me know if you don't see it in your inbox.

    Kindest Regards,
    Garry
     
    AdrianoVerona_Unity likes this.
  42. AdrianoVerona_Unity

    AdrianoVerona_Unity

    Unity Technologies

    Joined:
    Apr 11, 2013
    Posts:
    231
    Thanks Tiberius1701

    Your project helped us to fix some bugs

    Best

    Adriano
     
  43. Tiberius1701

    Tiberius1701

    Joined:
    Sep 16, 2014
    Posts:
    53
    You’re welcome! :)

    Kindest Regards,
    Garry
     
    AdrianoVerona_Unity likes this.
  44. ufot

    ufot

    Joined:
    Sep 11, 2013
    Posts:
    6
    Ok, late to the party...
    Recently converted an old pure UnityScript project.
    Ran into some problems running the conversion tool, but got it working in the end.
    Thought it might be a good idea to share the experience, since it might help someone else.

    Environment:
    MacOS High Sierra 10.13.3
    Unity 2017.3.0f

    1. Had no luck with running the tool in Unity.
    Could see some weird permission problem in logs.
    Also tried running the tool in old version of Unity (5.4), since the github page still recommends it.
    That info should probably be updated.

    2. Built the tool myself and ran it in command line.
    These are the steps I had to perform:

    + built the tool myself in Visual Studio for Mac and ran the .exe via mono from there (Visual Studio took care of all dependencies, much simpler than anticipated).

    + needed to run the tool as sudo (super user) otherwise I got a permission error in "something.../emscripten/node" (same as trying to run it from Unity).
    Seems to be related to a permission issue in web deployment code.

    + had to supply -r references

    Successfully USED the following command:

    Code (CSharp):
    1. sudo mono UnityScript2CSharp.exe -v -u /Applications/Unity2017 -p /PATH/TO/PROJECT/FOLDER -r /PATH/TO/PROJECT/FOLDER/Library/ScriptAssemblies/Assembly-CSharp.dll
    + had to copy UnityEngineUI.dll from Unity Application folder (unpacked it and found the .dll) and added it to the .dlls in the tools .exe folder (where the conversion tool's other .dll dependencies reside).
    I suspect this one might be project specific (perhaps NGUI related?).

    The result was very good.
    A day of cleanup and I was back on track.

    Thank you @Vagaus!
     
  45. AdrianoVerona_Unity

    AdrianoVerona_Unity

    Unity Technologies

    Joined:
    Apr 11, 2013
    Posts:
    231
    That is not expected. I'd like to see these permission errors you mentioned. If you can do me a favor, please, just try to convert the project (hopefully you have the last version based on UnityScript in your VCS repo :) ) and send me the Editor.log file.

    The Unity version you used (2017.3) should work fine.

    This should really not be necessary; I'll give a try with 2017.3 on MacOS. I'll even try to install this specific version instead of running out of my local built.

    Happy that in the end the conversion tool helped you :)

    Best

    Adriano
     
    Last edited: Mar 6, 2018
  46. CleanCut

    CleanCut

    Joined:
    Aug 19, 2013
    Posts:
    10
    I am also on 2017.3.0f3 (same as @ufot above).

    I installed the package and ran it via the menu item, and got

    Code (csharp):
    1. UnityScript2CSharp was not able to convert your project:.
    2.  
    3. The version of Unity passed as the Unity Editor path is too old. Details: Could not find the module assembly folder.
    4. Consider running converter with '-i' option.
    5.  
    6. UnityEngine.Debug:LogError(Object)
    7. UnityScript2CSharpRunner:ShowConversionResultsInConsole(Int32) (at Assets/UnityScript2CSharp/Editor/UnityScript2CSharpRunner.cs:231)
    8. UnityScript2CSharpRunner:RunConverter(String) (at Assets/UnityScript2CSharp/Editor/UnityScript2CSharpRunner.cs:210)
    9. UnityScript2CSharpRunner:Convert() (at Assets/UnityScript2CSharp/Editor/UnityScript2CSharpRunner.cs:92
    So I tried to follow @ufot's post above: I cloned the repository, and then downloaded and installed Visual Studio for Mac and built the project.

    For me, the command had the same error whether I used sudo or not -- same as the error above when running it through the editor. :(

    I captured and attached the output from two runs: First (cli_output.txt) was for running
    mono ./UnityScript2CSharp/bin/Debug/UnityScript2CSharp.exe -v -u /Applications/Unity2017.0 -p /path/to/project -r /path/to/project/Library/ScriptAssemblies/Assembly-CSharp.dll
    and then I added
    -i
    and captured that output in cli_output_i.txt

    Any help would be appreciated. :)
     

    Attached Files:

  47. AdrianoVerona_Unity

    AdrianoVerona_Unity

    Unity Technologies

    Joined:
    Apr 11, 2013
    Posts:
    231
    The error when you run from inside Unity Editor looks like a bug (I'll check tomorrow morning)

    Are you passing the path of a Unity version 2017.0 to the converter (-u /Applications/Unity2017.0) ? That would explain the error when you try to run from command line. If so, can you try to pass the path of a Unity 2017.3 installation ?

    Best
    Adriano
     
  48. AdrianoVerona_Unity

    AdrianoVerona_Unity

    Unity Technologies

    Joined:
    Apr 11, 2013
    Posts:
    231
    @CleanCut any update? Have you been able to run the converter ?
     
  49. jasonoda

    jasonoda

    Joined:
    Sep 7, 2012
    Posts:
    64
    Hi Adriano,

    I notice that when I run a small test project, I can convert the entire project...but on a bigger project, I have to convert one script at a time. The issue is that I have a lot of prefabs with the js scripts attached, and if I have to convert one by one, they don't get replaced by the new c# version. Going through everything to replace the scripts and copy the public variables is extremely tedious. What is the reason for not being able to convert large projects? Is there a way to bypass this?

    Also, isn't there a cleaner way to translate: gameObject.transform.position.x+1;
    Four lines makes things a bit cluttered.

    Thank you,
    Jason
     
  50. AdrianoVerona_Unity

    AdrianoVerona_Unity

    Unity Technologies

    Joined:
    Apr 11, 2013
    Posts:
    231
    Hi Jason

    Can you share your editor.log when try to convert the whole project? What happens in that case? Do you get an error?

    One possible alternative is for you to introduce a function in your UnityScript code that does that, replace all such assignments with a call to this function, run the converter; after that you may want to inline the generated function in C#.

    Adriano