- Learning C# 7 By Developing Games with Unity 2017(Third Edition)
- Micael DaGra?a Greg Lukosek
- 92字
- 2021-07-02 19:59:39
Using the NOT operator to change the condition
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 true. Let's add a NOT operator to our statement. Line 10 should now look like this:
if ( ! willItBeRainingToday ) {
Press Play in the editor. You will notice that the decision?1;making is now working the opposite way. Line 11 will be executed only if the willItBeRaining variable is false.