Search Unity

Problems with .js and .cs in the same project [Noob Problems]

Discussion in 'Scripting' started by qiqette, Feb 8, 2016.

  1. qiqette

    qiqette

    Joined:
    Feb 7, 2016
    Posts:
    121
    I know a bit of java, and 0 of C+, but my monodevelop dont want to autocomplete Unityscript code so i decided to make a project with C+, and i dont know a lot of things about c+

    Is it posible to have some scripts on js and others with cs? Will it hurt my performance?
     
  2. Hyblademin

    Hyblademin

    Joined:
    Oct 14, 2013
    Posts:
    725
    Not necessarily going to hurt performance, but there can be difficulties trying to make two different kinds of scripts reference each other, as I've heard. I would recommend against it anyway, because it's difficult to switch back and forth between syntaxes like that without making unnecessary mistakes and wasting time.

    From this answer:

    "Do note that writing JavaScript in Unity is not the same as writing it for web browsers (which is why it is popularly nicknamed UnityScript in the community)."

    If it matters, my preference is JavaScript. No real reason, it's just what was used in the tutorials I found a while back. I also find it usually takes less typing overall, but maybe it's just more compatible with my style.

    It's C#, by the way (C-sharp).
     
    qiqette likes this.
  3. Suddoha

    Suddoha

    Joined:
    Nov 9, 2013
    Posts:
    2,824
    Yes, it is possible to do that, performance-wise there shouldn't be a difference unless you use some exotic stuff that could be achieved easier.

    You just have to make sure the scripts from one language that you want to use in the other language will be compiled first. This can be done by putting it into folders like Plugins, or StandardAssets folder.

    You can then normally access all members.
     
    Kiwasi and qiqette like this.
  4. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    It can be done. But it's normally not worth the hassle. In most cases you will want to convert over to C# rather then use two languages.
     
    Suddoha likes this.