
Learning C# by Developing Games with Unity 3D Beginner's Guide
By :

The if statements work by determining whether a condition inside a pair of parentheses is true or false.
Modify LearningScript
as shown in the next screenshot.
Save the file.
In Unity, click on Play.
Here's the output in the Unity Console:
Code analysis:
The code on line 8 is as follows:
bool theBearMadeBigPottyInTheWoods = true;
This Boolean variable is declared and assigned the value of true
.
The code on line 10 and its description:
if( theBearMadeBigPottyInTheWoods)
An if
statement to test if the condition between the parenthesis is true
or false
.
The variable theBearMadeBigPottyInTheWoods
is storing a value true
, therefore.The code block on lines 11 to 13 is executed, as shown in the Console screenshot.
Here's a little curveball to wrap your mind around, the NOT logical operator. It's written in code using an exclamation mark. This makes a true condition false, or a false condition...
Change the font size
Change margin width
Change background colour