Learning C# Programming with Unity 3D: 1st Edition (Paperback) book cover

Learning C# Programming with Unity 3D

1st Edition

By Alex Okita

A K Peters/CRC Press

690 pages | 421 B/W Illus.

Purchasing Options:$ = USD
Paperback: 9781466586529
pub: 2014-08-01
$53.95
x
Hardback: 9781138413719
pub: 2017-07-27
$205.00
x
eBook (VitalSource) : 9781498760201
pub: 2015-09-15
from $25.98


FREE Standard Shipping!

Description

Designed to give you enough familiarity in a programming language to be immediately productive, Learning C# Programming with Unity 3D provides the basics of programming and brings you quickly up to speed. Organized into easy-to-follow lessons, the book covers how C# is used to make a game in Unity3D. After reading this book, you will be armed with the knowledge required to feel confident in learning more. You’ll have what it takes to at least look at code without your head spinning.

Writing a massive multiplayer online role-playing game is quite hard, of course, but learning how to write a simple behavior isn’t. Like drawing, you start off with the basics such as spheres and cubes. After plenty of practice, you’ll be able to create a real work of art. This applies to writing code—you start off with basic calculations, then move on to the logic that drives a complex game. By the end of this book, you will have the skills to be a capable programmer, or at least know what is involved with how to read and write code.

Although you could go online and find videos and tutorials, there is a distinct advantage when it comes to learning things in order and in one place. Most online tutorials for C# are scattered, disordered, and incohesive. It’s difficult to find a good starting point, and even more difficult to find a continuous list of tutorials to bring you to any clear understanding of the C# programming language. This book not only gives you a strong foundation, but puts you on the path to game development.

Table of Contents

Introduction

Why read a book

Do I need to know math?

Programming as a form of expression

Games as a stage with lights

Personal Information

A Brief History of Computer Programming

Mechanical Computers

Logic

Computer Science

Software

Modern Computer Language

The Future of Computer Languages

What is C#?

C# Paradigm

What is Unity3D?

Why Use Unity3D to Learn?

How does Unity3D use C#?

What Is Programming

What Does C# Look Like

Learning to copy and paste

Compiling

What We've Learned

Leveling Up

Before You Begin

What Will Be Covered in This Chapter

Getting Started: Downloading and Installing

Getting Started: Unity3D Overview

The Main Window

Creating a New Project

A New Unity Project

Summary

Getting Started: Sample Code

Code Fragments

Are errors bad?

Following along

Summary

Getting Started: Working with C#

Getting Project Files

Creating and Assigning a New C# File

Naming Your New File

Getting Started: Using Your New File

Unity Tools

Running Live Code

Saving a Scene

Opening a Scene

Summary

What We’ve Learned

Leveling Up

First Steps

What will be covered in this chapter

Review

First Steps: Tokens

Tokens

Separator Tokens

Operator Tokens

Other Operator Tokens

Literals

Transitive and Non-Transitive Operations

Putting It All Together

What We’ve Learned

First Steps: Statements and Expressions

Expressions

How Code is Executed

Thinking in Algorithms

What We’ve Learned

First Steps: Keywords

Class

What we’ve learned

First Steps: Whitespace

Pick a Flavor

What We’ve Learned

First Steps: Code Blocks

What We’ve Learned

First Steps: Classes

Objects

What We’ve Learned

First Steps: Variables

Identifiers

Data Noun: Collected Facts and Statistics Collected for Analysis

Declaring a Variable

Dynamic Initialization

What We’ve Learned

First Steps: Variable Names

Variable Assignment

Putting It Together

What We’ve Learned

First Steps: Types, a first look

Value and Reference Types

What We’ve Learned

First Steps: Strong Typing

Dynamic Typing

What We’ve Learned

First Steps: Type Casting, Numbers

Explicit vs. Implicit Casting

A Basic Example

What We’ve Learned

First Steps: Comments

Line Numbers

Code folding

Summary Comments

Navigating in Code

What We’ve learned

Leveling Up

Basics

What Will Be Covered in This Chapter

Review

Basics: Building Up a Game Idea

Design from Experience

Primary Activity

Moment to Moment

Actions to Functions

Compromise

Starting with Controls

What We’ve Learned

Basics: Creating a Class

Class Declaration

Adding Data Fields

Access Modifiers and the Dot Operator

Class Scope

Class Members

What We’ve Learned

Basics: Directives

Libraries

Ambiguous NameSpaces

What We’ve Learned

Basics: Functions

What are Functions

Unity Entry Points

Writing a Function

More on White Space, Tabs

What We’ve Learned

Basics: Order of Operation

What we've learned

Basics: Scope, a First Look

Class Scope

Function Scope

What We’ve Learned

Basics: This

A Basic Example

When This is Necessary

Awkward Names

What We’ve Learned

Basics: Turning Ideas into Code Part 1

Mouse Input

GameObject

What we’ve learned

Basics: Logic and Operators

Booleans

Equality Operators

If and Branching

Flow Charts

Relational Operators

Rearranging Logic

Another look at Scope

What we’ve learned

Basics: Loops

Unary Operators

While

For

Do While

Postfix and Prefix Notation

Using Loops

Loops within Loops

Runaway Loops

Breakpoints, a First Look

What We’ve Learned

Basics: Scope, Again

Visibility or Accessibility

A Basic Example

Global Scope

What We’ve Learned

Basics: Warnings vs Errors

Warnings

Errors

Understanding the debugger

What we’ve learned

Leveling Up

Style Guides

Fundamentals

What Will Be Covered in This Chapter

Review

Fundamentals: Inheritance, A First Look

Class members

Instancing

Parent and Child

Object

! = null

What We’ve Learned

Fundamentals: Instancing

Class Initialization

New

Constructors

What We’ve Learned

Fundamentals: Static

Static Variables

Static Functions

Putting it all together

What we’ve learned

Fundamentals: Turning Ideas into Code Part 2

Input Manager

What We’ve Learned

Fundamentals: Jump Statements:

Fundamentals: Jump Statements: Return 440

A Basic Example

Returning Objects

A Class is a Type

Null is Not Void

What We’ve Learned

Fundamentals: Operators, conditions

Conditional Operators && and ||

What We’ve Learned

Fundamentals: Arrays, a First Look

Fixed size Arrays

Foreach

Dynamically Initialization

While with Arrays

What we’ve learned

Fundamentals: Jump Statements: Break and Continue

A Basic Example

ZombieData

Foreach, again

What We’ve Learned

Fundamentals: Multi Dimensional Arrays

Colums and Rows

A Basic Example

A Puzzle Board

Checking Range

What We’ve Learned

Fundamentals: Array List

A basic example

ArrayList Contains

Remove

Sort and Reverse

What We’ve Learned

Fundamentals: Strings

Declaring a String

Escape Sequences

Verbatim Strings @

String Format

What We’ve Learned

Fundamentals: Combining what we’ve learned

Timers

Adding in Classes

What We’ve Learned

Fundamentals: Source Version Control

Modern Version Control

The Repository

Github

What We’ve Learned

Project Files

Setting up a Repository

Push

Gitignore

Pull

Contributors

What we’ve learned

Leveling Up

Intermediate

What Will Be Covered in This Chapter

Review

Intermediate: Pseudo Code

Thinking It Through

Class Members

Functions Return

Arguments aka "Args" (Not related to pirates)

Assignment Operators

What We’ve Learned

Intermediate: Class Constructors

A Basic Example

What We Learned

What We’ve Learned

Intermediate: Arrays, revisited

Using Arrays in Unity

Instancing with AddComponent();

Type Casting Unity Objects

What We’ve Learned

Intermediate: Enums

Using Enums

Combining what we’ve learned

What we’ve learned

Intermediate: Switch

A basic example

Default:

What We’ve Learned

Fall Through

Goto Case

Limitations

What We’ve Learned

Intermediate: Structs a.k.a. Structures

Structs 636

Struct vs. Class

Without Structs

Handling Structs

Accessing Structs

Global Access

What We’ve Learned

Intermediate: Class data

Character base class

Const

Readonly

What We’ve Learned

Intermediate: Namespaces

A Basic Example

Directives in Namespaces

Ambiguous References

Alias Directives

Putting Namespaces to Work

Extending Namespaces

What We’ve Learned

Intermediate: Functions again

Parameter Lists

Side Effects

Multiple Arguments

Useful Parameters

Foreach vs For

What We’ve Learned

Intermediate: Unity Execution order

A Basic Example

Component Execution Order

What We’ve Learned

Intermediate: Inheritance, Again

Function Overrides

A Basic Example

Class Inheritance

Object

What We’ve Learned

Intermediate: Type Casting, again

(≤Type≥) versus ‘as’

User-Defined Type Conversion

Implicit versus Explicit Type Conversion

Break;

What We’ve Learned

Intermediate: Working with Vectors

Vectors are Objects

Stepping through Monster Generator

Gizmos

A Basic Example

Using Gizmos

Optimizing

What We’ve Learned

Intermediate: Goto Labels

A Basic example

Zombie State Machine

This as a Reference to Yourself

HumanState based on ZombieState

The Is keyword

What have we learned

Intermediate: More on Arrays

Length and Count

Foreach, a Reminder

Discovery

Putting It Together

What We’ve Learned

Intermediate: Out Parameter

A Basic Example

Simple Sort (Bubble Sort)

Simple Sort Proof

What We’ve Learned

Intermediate: Ref Parameter

A Basic Example

Code portability Side Effects

What we’ve learned

Intermediate: Type Casting Numbers

Number Types

Integers

Floating Point

What We’ve Learned

Intermediate: Types and Operators

GetType()

More typecasting

Type Aliasing

Boxing and Unboxing

Intermediate: Operator Overloading

A Basic Example

Overloading *

Overloading ≤

What we’ve learned

Intermediate: Controlling Inheritance

Sealed 838

A Basic Example

Abstract

A Basic Example

Abstract : Abstract

Putting this to use

What we’ve learned

Leveling Up

Advanced

What Will Be Covered in This Chapter

Review

Moving forward

Advanced: Mono Develop

Find in Files

Word processors

Mono History

Advanced: Function Overloading

A closer look at functions

Function Signature

Different Signatures

Putting It Together

Not Quite Recursion

Drawword

What We’ve Learned

Advanced: Accessors a.k.a. Properties

value

A Basic Example

Set Event

Read Only Accessor

Simplification

What We’ve Learned

Advanced: Base Classes Another Look

Generalization – Base Classes

Specialization

Base

Partial

Protected Private and Public

What We’ve Learned

Advanced: Optional parameters

Using Optionals

Optional Arguments

Named Parameters

Combining What We’ve Learned

What We’ve Learned

Advanced: Delegate Functions

Delegates

Delegate Signatures

Stacking Delegates

Using Delegates

What We’ve Learned

Advanced: Interface

Early Planning

Interface Methods

Multiple Interfaces

IComparer

Using IComparer

What We’ve Learned

Advanced: Class Constructors Revisited

A Basic Example

When to Create a New Class

Static Functions

What We’ve Learned

Advanced: Preprocessor Directives

A Basic Example

UNITY_EDITOR

Warning

Organizing

What We’ve Learned

Advanced: Exceptions

A Basic Example

Exception Messages

Custom Exceptions

Finally

Try Catch Finally in Use

What We’ve Learned

Advanced: IEnumerator

IEnumerator

Implementing IEnumerator

What We’ve Learned

Advanced: Generics

Generic Functions

Making Use of Generic Functions

Generic Types

Var

Multiple Generic Values

What We’ve Learned

Advanced: Events

A Basic Example

A proper event

EventArgs

Update() to Event

Generic EventArg

What We’ve Learned

Advanced: Unity Friendly Classes

Extensions

A Basic Example

Inheriting from Object

OnUpdate

What We’ve learned

Advanced: Destructors

A Basic example

Clearing out objects

What we’ve learned

Advanced: Concurrency or Co-Routines

Yield 1088

A Basic Example

Setting Up Timers

Random Decisions with Logic

Stopping a Coroutine

What We’ve Learned

Advanced: Dictionary Stacks and Queues

A Basic Example

ContainsKey

Stacks

A Basic Example

Queues

What We’ve Learned

Advanced: Callbacks

A Basic Example

Dynamic Callback Assignment

WWW

What We’ve Learned

Advanced: Lambda Expressions

Anonymous Expressions

A Lambda Expressions

A Basic Example

When lambdas are Useful

Lambda Statements

What We’ve Learned

Leveling up

Extended

Extended: What we’ll be covering in this chapter

Extended: Review

Extended: Readability Optimizations and Idioms

?:

if

Smell

What We’ve Learned

Extended: Source Control Revisited

Diff and Merge

KDiff3

Avoiding Conflicts

What We’ve Learned

Extended: Debugging

Debugging Accessors

Locals

Call Stack

Watching List

What We’ve Learned

Extended: Recursion

A Basic Example

Understanding Recursion

In practice

Recursion Types

What We’ve Learned

Extended: Reflection

A Basic Example

Reflection MethodInfo

What We’ve Learned

Extended: LINQ

Lambdas and Arrays 1205

var

LINQ from

Strange behaviors in LINQ

Greedy Operator

What we’ve learned

Extended: Bitwise Operators

Big endian and Little Endian

Signed or Unsigned

Bitwise or |

Enums and Numbers

Bitwise and &

Bitwise Exclusive or ^ (xor)

Setting Bitwise Flags

Bitwise Shortcuts | = and ^ =

Bits in Numbers

Bit Shifting ≥≥ and ≤≤

What We’ve Learned

Extended: Bitwise Math

Twos Complement

Unary Operator ~

Bitwise Addition and Subtraction

Bitwise Multiplication

Bitwise Tricks

What We’ve Learned

Extended: Attributes

A Basic Example

Custom Attributes

Finding Custom Attributes

Attribute Constructor

Multiple Attributes

Putting Attributes to Work

Attribute flags

What We’ve Learned

Extended: Architectures and Organization

Planning Structure

Fixing Namespaces

Namespace and Directory Structure

Using Partial

Refactoring

What We’ve Learned

Extended: Design Patterns

Creational Design Patterns

Structural Design Patterns

Behavioral Design Patterns

What We’ve Learned

Extended: Continuing on Your Own

Stuff We Couldn’t Cover

Extern and unsafe

Dynamic

Dynamic vs Var

About the Originator

Author

Subject Categories

BISAC Subject Codes/Headings:
COM000000
COMPUTERS / General
COM012000
COMPUTERS / Computer Graphics
COM012040
COMPUTERS / Programming / Games