Scratching the surface of C# programming

We learned many ways to work with data. The code inside a method is where all the work is performed on the data, such as using the data to make decisions or modifying the data value. Even when Dot Syntax extracted data from another objects, all the work was performed in a method.

The C# code we used was rather basic, but we accomplished everything needed to create our game. Once again, that was the purpose of this book, to teach you the fundamental concepts of programming and use basic C# coding techniques to get the job done.

There are more C# techniques we could have used to make our code more efficient, and you may want to learn more about C#. But if you just want to understand enough C# to get some scripts written that are basic and easy to understand, then that's fine.

Understanding concepts can take a while to sink in before the lights turn on. So keeping the learning list short is important for a beginning programmer. This allows the basic concepts to be well-established before trying to learn some of the more advanced features of C# programming.

Looking at even more C# features

Some of the C# areas we didn't cover that you may want to look into are enumerations and switch statements. This could be useful to use to replace a lot of if-else statements when making logic decisions.

C# properties are slightly more advanced version of using variables. They allow more control over accessing or setting the data the variable will store.

Then there's even more advanced features such as the use of delegates or reflection features, which are definitely not appropriate for a beginner's book.

It all depends on what your goal happens to be, to get some simple scripts written or to make your code as efficient as possible with as few lines of code possible.

Just keep this simple rule in mind, write your code simple enough so another programmer can easily understand what it does, because in six months, you'll be that other programmer.

As you write your scripts, you know how it works and what it's supposed to do because you're writing it right now. In six months, all you will have is a vague memory of the code you write today, if you're lucky. I will bet that if your code isn't easily understandable, then in six month or more when you need to make a change, you'll come back and look at your code and say "What the heck is this trying to do? Who wrote this mess?"

Looking at even more Unity features

There are many Unity specific items not covered in this C# book. For example, we didn't specifically cover saving any data to disk, nor did we look at how to use coroutines.

This book would have been extremely long if everything about scripting was covered. It would have been much larger than the Scripting Reference. It also would have made you think you needed to learn everything before diving in and trying to write a code.

Remember that the Unity documentation is there so you don't have to know everything. With the basics of writing code under your belt, you can look into the Reference Manual and Scripting Reference to get and understand the code you want when it's needed.

The Scripting Reference documents all the behaviors you can apply to a GameObject. When you look in the Scripting Reference for a specific behavior, you are given the methods and variables needed, and some code to show you how to use them. Sometimes you may be able to use the example code as it is; but sometimes you'll need to modify the example code to fit your needs.

The point is, you know the fundamentals of variables, methods, and Dot Syntax. It will now be a lot easier to look at code examples in the Scripting Reference and figure out the details of its operation, and then apply it according to your needs.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.133.134.151