Mastering Unity Scripting

Learn advanced C# tips and techniques to make professional-grade games with Unity

Mastering Unity Scripting

Alan Thorn

1 customer reviews
Learn advanced C# tips and techniques to make professional-grade games with Unity
Mapt Subscription
FREE
$29.99/m after trial
eBook
$21.00
RRP $29.99
Print + eBook
$49.99
RRP $49.99
What do I get with a Mapt Pro subscription?
  • Unlimited access to all Packt’s 5,000+ eBooks and Videos
  • Early Access content, Progress Tracking, and Assessments
  • 1 Free eBook or Video to download and keep every month after trial
What do I get with an eBook?
  • Download this book in EPUB, PDF, MOBI formats
  • DRM FREE - read and interact with your content when you want, where you want, and how you want
  • Access this title in the Mapt reader
What do I get with Print & eBook?
  • Get a paperback copy of the book delivered to you
  • Download this book in EPUB, PDF, MOBI formats
  • DRM FREE - read and interact with your content when you want, where you want, and how you want
  • Access this title in the Mapt reader
What do I get with a Video?
  • Download this Video course in MP4 format
  • DRM FREE - read and interact with your content when you want, where you want, and how you want
  • Access this title in the Mapt reader
$0.00
$21.00
$49.99
$29.99p/m after trial
RRP $29.99
RRP $49.99
Subscription
eBook
Print + eBook
Start 30 Day Trial
Subscribe and access every Packt eBook & Video.
 
  • 5,000+ eBooks & Videos
  • 50+ New titles a month
  • 1 Free eBook/Video to keep every month
Start Free Trial
 
Preview in Mapt

Book Details

ISBN 139781784390655
Paperback380 pages

Book Description

This book is an easy-to-follow guide that introduces you to advanced tips and techniques to code Unity games in C#. Using practical and hands-on examples across ten comprehensive chapters, you'll learn how C# can be applied creatively to build professional-grade games that sell.

You will be able to create impressive Artificial Intelligence for enemy characters, customize camera rendering for postprocess effects, and improve scene management by understanding component-based architecture. In addition, you will have an in-depth look at the .NET classes used to increase program reliability, see how to process datasets such as CSV files, and understand how to run advanced queries on data. By the end of this book, you'll become a powerful Unity developer, equipped with plenty of tools and techniques to quickly and effectively develop merchantable games.

Table of Contents

Chapter 1: Unity C# Refresher
Why C#?
Creating script files
Instantiating scripts
Variables
Conditional statements
Arrays
Loops
Functions
Events
Classes and object-oriented programming
Classes and inheritance
Classes and polymorphism
C# properties
Commenting
Variable visibility
The ? operator
SendMessage and BroadcastMessage
Summary
Chapter 2: Debugging
Compilation errors and the console
Debugging with Debug.Log – custom messages
Overriding the ToString method
Visual debugging
Error logging
Editor debugging
Using the profiler
Debugging with MonoDevelop – getting started
Debugging with MonoDevelop – the Watch window
Debugging with MonoDevelop – continue and stepping
Debugging with MonoDevelop – call stack
Debugging with MonoDevelop – the Immediate window
Debugging with MonoDevelop – conditional breakpoints
Debugging with MonoDevelop – tracepoints
Summary
Chapter 3: Singletons, Statics, GameObjects, and the World
The GameObject
Component interactions
GameObjects and the world
The world, time, and updates
Immortal objects
Understanding singleton objects and statics
Summary
Chapter 4: Event-driven Programming
Events
Event management
Code folding in MonoDevelop with #region and #endregion
Summary
Chapter 5: Cameras, Rendering, and Scenes
Camera gizmos
Being seen
Orthographic cameras
Camera rendering and postprocessing
Camera shake
Cameras and animation
Cameras and curves
Summary
Chapter 6: Working with Mono
Lists and collections
IEnumerable and IEnumerator
Strings and regular expressions
Infinite arguments
Language Integrated Query
Linq and regular expressions
Working with Text Data Assets
Text Assets – loading from the local files
Summary
Chapter 7: Artificial Intelligence
Artificial Intelligence in games
Starting the project
Baking a navigation mesh
Starting an NPC agent
Finite State Machines in Mecanim
Finite State Machines in C# – getting started
Creating the Idle state
Creating the Patrol state
Creating the Chase state
Creating the Attack state
Creating the Seek-Health (or flee) state
Summary
Chapter 8: Customizing the Unity Editor
Batch renaming
C# attributes and reflection
Color blending
Property exposing
Localization
Summary
Chapter 9: Working with Textures, Models, and 2D
Skybox
Procedural meshes
Animating UVs – scrolling textures
Texture painting
Summary
Chapter 10: Source Control and Other Tips
Git – source control
Resources folder and external files
AssetBundles and external files
Persistent data and saved games
Summary

What You Will Learn

  • Understand core C# concepts, such as class inheritance, interfaces, singletons, and static objects
  • Implement effective Artificial Intelligence for NPCs
  • Work with event-driven programming to optimize your code
  • Develop solid debugging and diagnostic techniques
  • Get to know the Mono Framework and Linq in practical contexts
  • Customize the rendering functionality for postprocess effects
  • Code line of sight, view testing, and other useful algorithms
  • Improve the quality of your code with the help of concepts such as attributes

Authors

Table of Contents

Chapter 1: Unity C# Refresher
Why C#?
Creating script files
Instantiating scripts
Variables
Conditional statements
Arrays
Loops
Functions
Events
Classes and object-oriented programming
Classes and inheritance
Classes and polymorphism
C# properties
Commenting
Variable visibility
The ? operator
SendMessage and BroadcastMessage
Summary
Chapter 2: Debugging
Compilation errors and the console
Debugging with Debug.Log – custom messages
Overriding the ToString method
Visual debugging
Error logging
Editor debugging
Using the profiler
Debugging with MonoDevelop – getting started
Debugging with MonoDevelop – the Watch window
Debugging with MonoDevelop – continue and stepping
Debugging with MonoDevelop – call stack
Debugging with MonoDevelop – the Immediate window
Debugging with MonoDevelop – conditional breakpoints
Debugging with MonoDevelop – tracepoints
Summary
Chapter 3: Singletons, Statics, GameObjects, and the World
The GameObject
Component interactions
GameObjects and the world
The world, time, and updates
Immortal objects
Understanding singleton objects and statics
Summary
Chapter 4: Event-driven Programming
Events
Event management
Code folding in MonoDevelop with #region and #endregion
Summary
Chapter 5: Cameras, Rendering, and Scenes
Camera gizmos
Being seen
Orthographic cameras
Camera rendering and postprocessing
Camera shake
Cameras and animation
Cameras and curves
Summary
Chapter 6: Working with Mono
Lists and collections
IEnumerable and IEnumerator
Strings and regular expressions
Infinite arguments
Language Integrated Query
Linq and regular expressions
Working with Text Data Assets
Text Assets – loading from the local files
Summary
Chapter 7: Artificial Intelligence
Artificial Intelligence in games
Starting the project
Baking a navigation mesh
Starting an NPC agent
Finite State Machines in Mecanim
Finite State Machines in C# – getting started
Creating the Idle state
Creating the Patrol state
Creating the Chase state
Creating the Attack state
Creating the Seek-Health (or flee) state
Summary
Chapter 8: Customizing the Unity Editor
Batch renaming
C# attributes and reflection
Color blending
Property exposing
Localization
Summary
Chapter 9: Working with Textures, Models, and 2D
Skybox
Procedural meshes
Animating UVs – scrolling textures
Texture painting
Summary
Chapter 10: Source Control and Other Tips
Git – source control
Resources folder and external files
AssetBundles and external files
Persistent data and saved games
Summary

Book Details

ISBN 139781784390655
Paperback380 pages
Read More
From 1 reviews

Read More Reviews