Talk:Head First into Unity with UnityScript

From Unify Community Wiki
Jump to: navigation, search

About A note on how to "Split" Strings: I think the example might confusing, the example text should be something un-related that can not be mistaken for code... col000r 00:56, 19 August 2009 (PDT)

Why does this article consistently refer to UnityScript as JavaScript, and not even JScript.NET? The two languages are completely unlike each other; UnityScript has about in much in common with JavaScript as Java has in common with JavaScript. Ppeterson 02:49, 21 November 2010 (PST)

@Ppeterson: Because that's what the Unity documentation calls it. By the way, regarding your edit about "var" being required: that's not actually true. It's only required if you use #pragma strict and don't use #pragma implicit. Also, Javascript in Unity isn't JScript.NET. It used to be almost identical (aside from the built-in Array class, maybe a few other things), but in Unity 3 it's increasingly different, with the inclusion of generics and some other stuff. I'm not sure the advice to learn Java instead of Javascript is particularly helpful; even though the structure of Java is more like Unityscript, the syntax is like C#. Either one is sufficiently different that I don't think it really matters. Eric5h5 11:52, 21 November 2010 (PST)

Math is Mathf; Math.abs is Mathf.Abs

JavaScript's annoying Math library (because, really, stuff like abs() should just be in the language) becomes Unity's (also annoying) Mathf library. And remember, method names are usually capitalized (in Unity) so Math.abs() becomes Mathf.Abs().

I know it may be annoying, but with global namespace pollution as bad as it is, it would be better for the Math API to stay within its own namespace. Besides, the mutable nature of Javascript means that anyone can overwrite just about any function -- even those pre-built for the language. -U4yk

"Global namespace pollution" is a straw man. Anyone defining a global called "sin" or "abs" deserves what they get. That said, Math.sin is not a huge annoyance -- but why Mathf.Sin when there is no Math? - Podperson
If you call "using System;" (which usually you do in .NET) there's a class called Math. Ppeterson (talk) 17:58, 24 February 2013 (CET)
Personal tools
Namespaces

Variants
Actions
Navigation
Extras
Toolbox