When creating our first code, the tradition is to create "hello world" as our very first code. To do this, we need to do the following:
In MonoDevelop, within the file we have just created and named
HelloWorld
, we create a variable under#pragma strict
.To create a variable, we declare it by typing
var
.Follow this by typing
greeting
—the name of the variable.Then, we use a colon
:
to declare the type that the variable will be using, followed by typing out the string typeString
as we want to store text in our variable. We need to ensure that we useString
with an uppercase S; otherwise, we will get an error.We then use the assignment operator
=
followed by the text "Hello World!
" with quotes to assign the variable with text and thus initialize it.We always finish a line with a semicolon
;
.We then use the UnityScript function
print
by typing out "print" to print out our text, and we pass it the variable we just created so that it will print the information stored within the variable...