Ok guys, very sorry if this doesn’t fit anywhere but I gotta know.
What the hell does the : do in javascript/unityscript?
For example:
var backDrop:Texture2D; //HERE
var windowPosition:Vector2=Vector2(200,200);
var windowSize:Vector2=Vector2(96.0,96.0); //AND HERE
var itemIconSize:Vector2=Vector2(32.0,32.0); //AND HERE
var updateListDelay=1.0;
var lastUpdate=0.0;//last time we updated the display.
var UpdatedList:Transform[];
var associatedInventory:Inventory; //LASTLY, HERE
And bonus question, how would one translate that into Boo?
Boo is based on Python (which was primarly a script too). I would think it is used inside Unity since you can see it mentioned on some type of errors in the console. BUt apart from that it is barely used and as barely used no one starts with it (vicious circle).
The : and the thing that follows it enforce a ‘type’ on that variable. Without it, it’s just a generic object. With it, you know that something is really a Texture2D or Vector2 or Transform etc.
Used in a function it indicates the return type. Just complementing the answer, you knew that.
I find it easier not to think of unity javascript as javascript, so I think of it as unityscript.
Even so I like the possibilities of explicit typing in unity’s javascript, it makes the code easier to read IMHO, its quite easy to get yourself in a mess with strings and number data types in javascript “proper”. Very rarely need to debug simple type issues if at all in Unity.
Boo is based on Python (which was primarly a script too). I would think it is used inside Unity since you can see it mentioned on some type of errors in the console. BUt apart from that it is barely used and as barely used no one starts with it (vicious circle).
– fafase