Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

How to change script language to JavaScript ?

Discussion in 'Scripting' started by munasib7hossain, Jan 22, 2015.

  1. munasib7hossain

    munasib7hossain

    Joined:
    Jan 22, 2015
    Posts:
    1
    My scripting language in c# by default. But because I am finding it increasingly difficult, I want to change it to JS. Please tell me how .
     
  2. hpjohn

    hpjohn

    Joined:
    Aug 14, 2012
    Posts:
    2,190
    Instead of clicking "Assets -> Create -> C# Script", click Javascript...?

    Unless you mean the documentation, There's buttons at the top right to choose language

    Or just get used to c#. The syntax differences are pretty small c# is better
     
  3. BenZed

    BenZed

    Joined:
    May 29, 2014
    Posts:
    524
    I strongly encourage you to stick with C#.

    The "javascript" you're learning here isn't real javascript. I'm not going to say the skills arn't transferrable, but there are structures and tenants in unity javascript that only exist in unity javascript. If you learn C# for unity, you'll know it for everything else, too.
     
    HelloMeow likes this.
  4. Jessy

    Jessy

    Joined:
    Jun 7, 2007
    Posts:
    7,325
    If you had to come the forum to ask about this, you are not ready to assess that UnityScript is easier to use. You have to get over the difficulty hump of learning to use the Editor first. Reading manuals is hard for some people. If it is, for you, you may want to have an Irlen assessment.

    Although I agree that you should use C# until something better comes along, I do not agree that it's important to know for anything else, because all the anythings else I can think of are either Xamarin or .NET development, neither of which are good for the universe. :rolleyes: I have found it useful to know C#, when on the Swift discussions boards, because although Swift is a better language than C# for all the features it does have, it is still missing some, but people coming from Objective-C don't always know about what's still missing.
     
  5. cmcpasserby

    cmcpasserby

    Joined:
    Jul 18, 2014
    Posts:
    315
    Just asking but what makes you feel swift is a better language than c#, really both languages have the same drawback if being to closky coupled and controlled by 1 company.

    But feature wise they are pretty much the same with what I believe cleaner syntax on the C# side as far as types go. Though I do like the lack of the new key word in swift and how dicts and lists are made since it feel more like python.
     
  6. Jessy

    Jessy

    Joined:
    Jun 7, 2007
    Posts:
    7,325
    The most important difference is that Swift is the first language that I consider "modern" without a garbage collector. The most important missing feature is multicast delegates.
    I don't see that as a drawback. In order to see it that way, you'd have to imagine yourself as something different than the company who controls the language. I view them as parts of whatever I am that are harder to control than most other parts, but still easier than the whole of humanity. I prefer the focus.
    I am interested to see what syntax differences led to this opinion. I think the languages are identical in what I'm imagining.
     
    Last edited: Jan 22, 2015
  7. cmcpasserby

    cmcpasserby

    Joined:
    Jul 18, 2014
    Posts:
    315
    By controlled i was referring to how each is kinda stuck with ms or apple and tied to a operating system or range of products. Exemple I can't even test swift since I got rid of all my macs 3 years ago. Was bad wording on my part but was comparing to say or java or python where it is write once run it everywhere type deal.

    How does it manage no GC, c++ style pointers to memory? Referwnce counting
     
    Last edited: Jan 22, 2015
  8. Tiles

    Tiles

    Joined:
    Feb 5, 2010
    Posts:
    2,481
    Most older Unity books are written with Unity JS. So Amazon might be your friend here.
     
    Jessy likes this.
  9. BenZed

    BenZed

    Joined:
    May 29, 2014
    Posts:
    524
    I agree. I don't like how swift handles access modifiers, but other than that I like it a lot. I'd be pumped if it became available for other environments. Like unity.
     
    Jessy likes this.
  10. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    There is no magic button to change existing scripts to JS. You will have to do this line by line. You'll also have to change the file extensions. It may be easier to create a new script and copy paste. You'll probably need to reassign the scripts in the inspector too.

    When people say JS is easier they are typically referring to the initial stages. Ultimately you still have to learn types.

    C# will force you to learn them at the start, "Don't know what a float is? You can't do anything! Mua ha ha".

    Java Script pushes that learning out, "Never heard of a float before? Don't worry, I got this. Make your code." Then it hides in the bushes for a few weeks, until one day, "Don't know what UnityEngine.object is? Mua ha ha ha ha!"

    Everything else between the languages is pretty much just syntax. My experience has been it's far easier to learn type from the outset, when you are dealing mainly with primitives and other simple types. Learning about types when your scripts are already relatively complex can be painful.

    If you've tried C# and it doesn't work for you, by all means, try Java Script. Just pointing out that it's probably not going to be the cure all you are hoping for.
     
  11. borishthm

    borishthm

    Joined:
    Jun 6, 2020
    Posts:
    1
    My scripting language in c# by default. But because I am finding it increasingly difficult, I want to change it to JS. Please tell me how .
     
  12. Laperen

    Laperen

    Joined:
    Feb 1, 2016
    Posts:
    1,065
    Pretty sure UnityScript(the javascript-like language for unity at the time) has been deprecated entirely by now. In my experience though, both JS and C# are going to be equally hard to learn if you're just starting to delve into scripting as a whole.
     
  13. hpjohn

    hpjohn

    Joined:
    Aug 14, 2012
    Posts:
    2,190
    Documentation no longer contains ANY reference material for UnityScript ('JS')
    You will will find it MUCH harder to try using js without it. Push through the difficulty, C# is the correct langugae to use.
     
  14. UnityMaru

    UnityMaru

    Community Engagement Manager Unity Technologies

    Joined:
    Mar 16, 2016
    Posts:
    1,227
    Please don't necro post :)