Hello! Sorry for my ignorance, but I am new to unity.
I noticed while watching tutorials, there are C# and Javascript options when writing your code/scripts for the actors. If I am doing 2D mobile games on Unity, is there a specific script type we have to use per platform?
For example if publishing on Android use Java, if publishing on iOS use C#?
Or can I just learn one type and use it for all my games?
I have created mobile games in Gamesalad (no coding) and it automatically formats it to whatever platform you choose when you create a build, but it does not have all the capabilities of real programming.
Is there a preference out there?
Do all languages have the same capabilities, just different code?
Are there any platforms that require specific script types (like nintendoDS or anything)?
Are most Asset Store things programmed in a certain language?
ok, first up, it’s not “real” Javascript in the sense that it’s the same Javascript that’s used in web programming or where ever else. Around the forums it’s usually called UnityScript to disambiguate.
The language you write your game in is totally irrelevant to what you are building, it all gets compiled when you “build” the game so it’s down to your preference. If unity lets you build for that platform the code (with a few tweaks based on the platform’s features) will work on whatever platform you’ve picked.
yes, learn c#
c# is more widely applicable outside of unity, it’s got much better documentation in general being a widely used language, there is a slight trend to move newer unity features and their documentation in c# only, see UNet docs etc.
Thanks a lot @LeftyRighty , makes perfect sense. If all languages have the same outcome, I might as well learn the one that can be used outside of Unity also
I second the c# option. Maybe its selection bias but as I recall most community support and examples that people give on this forum is in c# . It’s not that hard to convert little snippets back and forth between languages, but still for someone just starting it makes sense to choose. The official docs do have examples in both languages though!
Other than that like has already been said Unity will compile whatever language you use so it’s all kind of “the same” in the end either way.
You’re evil… and technically incorrect. He stopped using Unity. The one you meant to tag was @ippdev . There are more developers than just him but he’s one of the more vocal users and more than willing to give his opinion on the matter.
I still like US better for things like scope of variables within functions and nested for loops. Much easier to handle yield statements with. I have about half my working projects in C#, including most of my clients and I can write both just as easily. C# just ticks me off with having to tell it like it is deaf that I already declared the danged thing or I just want to target the .x value without recreating the wheel. Other than that the way I learned to code was via components so either C# or US I do basically the same thing but talk like Yoda in C# when declaring. Still doesn’t change the fact there is a gawdawful mess of C# out there in projects that should never have made it’s way into game mechanics code I have had to fix up for clients.
Just got a few questions about Unityscript coming from a novice Unity user.
First of is Unityscript going away anytime soon?
I much rather use Unityscript as I am a javascript developer at work, and if you compare Unityscript with Typescript they are very similar.
Also is there proper editor(Visual studio) support for unityscripts? for example something like this but for Unityscript Visual Studio Code and Unity
The lack of resources and learning tools for the language is not that big of a deal I think, but the absence of a proper editor implementation is a bigger hurdle to overcome.
A grand appeal via a broadbrushed statement. I have seen way more horrendous C# in my days freelancing (7 years in Unity) and having all kinds of Asset Store packages and other codebases land in my lap. The majority of .us code is readable, understandable and is …if you will… proper game mechanic code. The C# code i am complaining about looks like it was cut and pasted ad inifnitum from MS dev sites. There are many learning resources for .us. The wiki has dozens of .js scripts with comments. Once .us syntax is understood as well as it’s syntactical sugar which leads to less verbose code in many cases then the transferance of .cs to .js is no big deal. Vice versa as well. There is little community support due to the asshattery of some C#-ers and most of the .JS-ers would rather go about the business of game dev than argue here. Perhaps i suggest that due to the easier understanding and syntactical sugar of .js that there is much less need to ask for assistance. I never have to guess the syntax. Mind you, I have years more experience with the engine than you in both codebases.
What is meant by a proper editor implementation? If you mean a text editor that syncs with the console and goes to the correct lines in the warning then I still use Unitron for .js scripting.
Everything @Kiwasi said is true - if perhaps slightly biased in one direction. Unitron is no longer maintained and is Mac only. And “syncing” to the console doesn’t even count. I could write code in Notepad and the console would report errors on the correct line. We’re talking about intellisense, auto complete proposals, debugger functionality, code refactoring and traversal tools. All the things a professional IDE provides. And sorry, but a Wiki with “dozens” of scripts pales in comparison to the reams of material available for C# - which would be expected since C# has been around longer than Unity and is used in a much wider array of contexts.
With all that said - stop it. For the love of all that is good in this world; stop. Use the language and the tools that you want to - no one cares. What’s been said about the growing ubiquity of C# is true and new users should know the reality of the situation. If you still want to use UnityScript then go ahead. That decision doesn’t make you less of a programmer or person or whatever else UnityScript users get defensive about when these topics come up. Crap code exists in every computer language ever conceived by man - UnityScript is not somehow special or exempt in this regard.
Stop what?? commenting on threads I was tagged on and giving my opinion? If so…just stop…please stop. This is why there are very few threads on using .js in Unity as of late. It is that language that is not to be discussed.
Debating the realities of Unity’s ecosystem and the resources available to new and experienced users is one thing. Calling C# users asshats and vaguely suggesting that the dearth of UnityScript material is somehow a well-orchestrated cover up by those same asshats is ridiculous and non-productive.
Feel free to cite cases beyond nebulous assertions like US is “less verbose”, “easy once you understand the syntax and syntactical sugar”, and you “think it’s easier to read”. All languages become easier when you know the syntax and the ones you know better are easier to read.
Again - I’m saying use what you want to use but understand the risks of using the language that has less support.