
Unity 4.x Game Development by Example: Beginner's Guide
By :

The ClockScript was fairly painless to convert to C#. These were the steps:
Copy/paste the JavaScript code into a new C# script (keeping the C# class definition and omitting the #pragma strict line)
Add the appropriate access modifier to the variable definitions (note: any variables that need to show up in the drag-n-drop Unity interface, like the ones that store the textures, need the public
modifier. Use private
for all other variables)
Change the syntax of all the variable definitions (declare the type before the variable name, and nix the colon)
Change the function declarations so that they start with the return type (void
in all cases for this script) and an access modifier (private
for all of these functions)
Add the new
keyword when defining a Rect
or a Vector2
instance
Explicitly cast variables when you convert a float to an int. See this line for an example:
minutes = (int)(timeRemaining/60); // minutes is an int, while timeRemaining is a float
Remember that if you remove...
Change the font size
Change margin width
Change background colour