I noticed there seems to be a large number of aspiring game developers that dive into Unity without learning C# first. Although I think it’s a good idea to learn C# first, game development is a different way of thinking, and Unity’s codebase doesn’t conform to C# standards in many ways.
The book even claims it’s a good book for those who know C# but “need to get hands-on with game development in Unity”. So, does this book do a good job of teaching C# in the context of Unity? I’d say no. The problem is that a lot of the content is either poorly described, ambiguous, or misleading. Then sometimes the writing style is more conversational/casual (perhaps would be harder for non-native speakers): "we’ll be diving into that in the next section—hold tight.". "To Unity, it walks, talks, and acts like any other component, complete with public variables underneath the component that can be changed at any time."
I’ll discuss some of the ambiguous and misleading elements of the book:
“It could simply call the SendMail function from the PostOffice class, as follows: PostOffice().SendMail()”. This isn't true because PostOffice isn't a method in his example - it is a class. Therefore the syntax would require the "new" keyword.
Does this explanation actually make sense or aid comprehension? I find it a weird analogy:
“Variables hold values like mailboxes hold letters; methods store instructions like recipes, to be followed for a predefined result; and classes are blueprints just like real blueprints.”
He initially declares variables in PascalCase, then claims that is the C# standard, yet Pascal case is for Properties and method names. Then in Chapter 5, he switches to camelcase, then occasionally uses an underscore prefix in subsequent chapters.
"While explicit access modifiers aren’t necessary when declaring a variable, it’s a good habit to get
into as a new programmer. That extra word goes a long way toward readability and professionalism
in your code". Apart from the fact that he is specifically talking about fields. If it is a local variable, then the access modifiers are completely invalid. Access modifiers are necessary in certain contexts, so that's not a correct statement anyway.
In regards to using time.deltaTime, he describes it as “This is the standard way of normalizing movement effects in Unity so that they look smooth no matter how fast or slow the player’s computer is running.” It’s quite an important aspect of Unity programming, and a basic explanation isn’t really good enough. It’s not so much as looking smooth, rather than actually being the correct calculation over time. At a low framerate, nothing is going to look smooth.
“By default, all arguments are passed by value, meaning that a variable passed into a method will not be affected by any changes that are made to its value inside the method body.” It’s a bit complicated, but this isn’t really true with reference types: MSDN even says “If the method modifies the state of the object referred to by the parameter, those changes are visible from the caller.”
I thought there were fewer mistakes in the latter half of the book, but then I also think I was skim-reading more frequently, so maybe I wasn’t paying attention. In conclusion, I think there’s way better resources for learning the basics of C# out there, and there’s way better books for learning Unity.