Unity from Proficiency to Mastery: C# Programming

Master C# with Unity

| Book Files | Free Book Sample |

Book Description

In this book, which is the second in the series Unity from Proficiency to Mastery, you will learn how to master C# and how it is used in Unity for common game mechanics; you will also learn how to optimize your code and make it more maintainable over time.

What you will Learn

After completing this book you will be able to:

  • Master programming basics: variables, methods, classes
  • Understand Object-Oriented Concepts
  • Understand and apply linear algebra in C# for Unity
  • Understand how key game elements can be implemented in C# (detection, audio, timers, type casting and conversion, user inputs, file access, etc.)
  • Know why and how to employ useful structures (Enums, Lists, Coroutines, Scriptable objects, events, delegates, etc.)
  • Optimize your code (memory management, defensive coding, component-based architecture)

Topics covered in this book:

Topics covered in this book include:

  • Creating C# scripts.
  • Debugging C# scripts.
  • Variable, methods and scope.
  • Common Errors.
  • using and manipulating Vectors.
  • Combining C# and Unity.
  • Instantiating, Deactivating, and Destroying Objects.
  • Communicating between scripts.
  • Detecting user’s inputs on different devices.
  • Using Rigidbody components.
  • Colliders and Triggers.
  • Ray-casting.
  • Opening XML files.
  • Scriptable objects.

Key features

  • A step-by-step approach with plenty of examples to know exactly what to do.
  • Tips to maximize your workflow.
  • Quizzes to tests your knowledge at the end of each chapter.
  • Challenges to use and perfect your skills at the end of each chapter.
  • A section with answers to frequently asked questions organized by themes (e.g., navigation, object creation, interface, etc.).
  • A cook book with recipes that you can use based on what you need.

Book Structure

  • Chapter 1, Introduction to C# programming, provides an introduction to C#, so that you become comfortable with coding in C# programming and with Object-Oriented concepts.
  • Chapter 2, Creating your First Script, provides step-by-step instructions so that you can start creating your own scripts in Unity and implement some of the concepts introduced in the first chapter. You will also learn best coding practices, as well las how to debug your code and make it work smoothly.
  • Chapter 3, Introduction to Linear Algebra with C# for Unity, provides an introduction to vectors; you will learn how to perform useful operations with vectors, and how these can be used in Unity and your games.
  • Chapter 4, Combining C# and Unity Objects, provides practical explanations on using C# in your games. It identifies and illustrates some of the key (and frequently used) functions and classes that you would normally employ to create a game in Unity; both code snippets and in-depth explanations are provided. This section can also be used as a cook book, whereby you can go straight to the section that you need for your game.
  • Chapter 5, Optimizing The Structure and Efficiency of Your Code, explains how it is possible to optimize your code, and the overall structure of your game, so that your game is faster, more responsive (to provide a great user experience), and easy to maintain over time.
  • Chapter 6 provides answers to Frequently Asked Questions (FAQs) related to the topics covered in this book.
  • Chapter 7 summarizes the topics covered in this book and provides you with more information on the next steps to follow.