Professional Documents
Culture Documents
(Download PDF) Learning C Programming With Unity 3D Alex Okita Online Ebook All Chapter PDF
(Download PDF) Learning C Programming With Unity 3D Alex Okita Online Ebook All Chapter PDF
(Download PDF) Learning C Programming With Unity 3D Alex Okita Online Ebook All Chapter PDF
3D Alex Okita
Visit to download the full and correct content document:
https://textbookfull.com/product/learning-c-programming-with-unity-3d-alex-okita/
More products digital (pdf, epub, mobi) instant
download maybe you interests ...
https://textbookfull.com/product/c-game-programming-cookbook-for-
unity-3d-2nd-edition-jeff-w-murray/
https://textbookfull.com/product/learning-c-7-by-developing-
games-with-unity-2017-learn-c-programming-by-building-fun-and-
interactive-games-with-unity-third-edition-micael-dagraca/
https://textbookfull.com/product/beginning-game-ai-with-unity-
programming-artificial-intelligence-with-c-sebastiano-m-cossu/
Developing 2D Games with Unity: Independent Game
Programming with C# 1st Edition Jared Halpern
https://textbookfull.com/product/developing-2d-games-with-unity-
independent-game-programming-with-c-1st-edition-jared-halpern/
https://textbookfull.com/product/developing-2d-games-with-unity-
independent-game-programming-with-c-1st-edition-jared-halpern-2/
https://textbookfull.com/product/game-programming-in-c-
creating-3d-games-creating-3d-games-sanjay-madhav/
https://textbookfull.com/product/getting-started-with-
unity-2018-a-beginner-s-guide-to-2d-and-3d-game-development-with-
unity-3rd-edition-edward-lavieri/
https://textbookfull.com/product/deep-reinforcement-learning-in-
unity-with-unity-ml-toolkit-1st-edition-abhilash-majumder/
Learning C# Programming
with Unity 3D
Learning C# Programming
with Unity 3D
Second Edition
Alex Okita
CRC Press
Taylor & Francis Group
6000 Broken Sound Parkway NW, Suite 300
Boca Raton, FL 33487-2742
This book contains information obtained from authentic and highly regarded sources. Reasonable efforts have been made
to publish reliable data and information, but the author and publisher cannot assume responsibility for the validity of all
materials or the consequences of their use. The authors and publishers have attempted to trace the copyright holders of all
material reproduced in this publication and apologize to copyright holders if permission to publish in this form has not been
obtained. If any copyright material has not been acknowledged please write and let us know so we may rectify in any future
reprint.
Except as permitted under U.S. Copyright Law, no part of this book may be reprinted, reproduced, transmitted, or utilized
in any form by any electronic, mechanical, or other means, now known or hereafter invented, including photocopying,
microfilming, and recording, or in any information storage or retrieval system, without written permission from the
publishers.
For permission to photocopy or use material electronically from this work, please access www.copyright.com (http://www.
copyright.com/) or contact the Copyright Clearance Center, Inc. (CCC), 222 Rosewood Drive, Danvers, MA 01923, 978-750-8400.
CCC is a not-for-profit organization that provides licenses and registration for a variety of users. For organizations that have been
granted a photocopy license by the CCC, a separate system of payment has been arranged.
Trademark Notice: Product or corporate names may be trademarks or registered trademarks, and are used only for
identification and explanation without intent to infringe.
v
vi Contents
8. Extended........................................................................................................................................ 579
8.1 What We’ll Be Covering in This Chapter ........................................................................ 579
8.2 Review .............................................................................................................................. 579
8.3 Readability .........................................................................................................................581
8.3.1 ?: Notation ..........................................................................................................581
8.3.2 If ........................................................................................................................ 582
8.3.3 Smell ................................................................................................................. 583
8.3.3.1 Comments ......................................................................................... 583
8.3.3.2 One Responsibility Rule ................................................................... 583
8.3.3.3 Duplicated Code ............................................................................... 584
8.3.3.4 Naming ............................................................................................. 584
8.3.4 What We’ve Learned ........................................................................................ 584
8.4 Git Revisited ..................................................................................................................... 584
8.4.1 Git Branch and Merge ....................................................................................... 585
8.4.2 Merge Conflicts ................................................................................................. 588
8.4.3 What We’ve Learned .........................................................................................591
8.5 Recursion ...........................................................................................................................591
8.5.1 A Basic Example ............................................................................................... 593
8.5.2 Understanding Recursion .................................................................................. 593
8.5.3 In Practice ......................................................................................................... 594
8.5.4 What We’ve Learned ........................................................................................ 601
8.6 LINQ ................................................................................................................................. 601
8.6.1 Lambdas and Arrays ......................................................................................... 601
8.6.1.1 A Basic Example .............................................................................. 601
8.6.2 Var ..................................................................................................................... 602
8.6.3 LINQ From ....................................................................................................... 603
8.6.4 Strange Behaviors in LINQ .............................................................................. 604
8.6.5 LINQ on Lists ................................................................................................... 605
8.6.6 Monsters Linq ................................................................................................... 608
8.6.7 What We’ve Learned .........................................................................................611
8.7 Reflection ...........................................................................................................................613
8.7.1 A Basic Example ................................................................................................615
8.7.2 Reflection MethodInfo .......................................................................................615
8.7.3 What We’ve Learned .........................................................................................618
8.8 Dynamic............................................................................................................................ 620
8.8.1 ExpandoObject ...................................................................................................621
8.8.2 Expando Reader ................................................................................................ 622
8.8.3 What We’ve Learned ........................................................................................ 623
8.9 Bitwise Operators ............................................................................................................. 624
8.9.1 Big Endian and Little Endian ........................................................................... 624
8.9.2 Signed or Unsigned ........................................................................................... 625
8.9.3 Bitwise Or | ....................................................................................................... 627
8.9.4 Enums and Numbers ......................................................................................... 627
8.9.5 Bitwise And & .................................................................................................. 628
8.9.6 Bitwise Exclusive Or ^ (xor) ............................................................................. 629
8.9.7 Setting Bitwise Flags ........................................................................................ 630
8.9.8 Bitwise Shortcuts | = and ^ = .............................................................................631
8.9.9 Bits in Numbers ................................................................................................ 632
8.9.10 Bit Shifting >> and << ..................................................................................... 632
8.9.11 What We’ve Learned ........................................................................................ 634
8.10 Attributes .......................................................................................................................... 635
8.10.1 A Basic Example ............................................................................................... 635
8.10.2 Custom Attributes ............................................................................................. 639
10 Learning C# Programming with Unity 3D
The combination of the central processing unit (CPU) and operating system is often called a platform.
Each platform requires a unique native machine code to execute or run. Building code for each platform
is called a target. Unity 3D converts the bytecode into a native machine code and can target Mac, PC,
Android, and iOS.
Native machine code is the set of instructions that directly talk to the CPU and operating system (think
of the holes punched into a card and fed to a machine). Unity 3D is a simple way to generate the complex
set of instructions for your computer to run. Code that talks directly to the hardware is referred to as
“low-level” programming.
There are layers of software between you and the computer’s hardware. When writing C# for games
using Unity 3D, your code is compiled by .NET. Unity 3D then takes the bytecode from .NET and com-
piles a target platform into a native machine code.
Both Unity 3D and .NET are the layers underneath your code and the computer’s hardware, putting
you on a higher level. This is often referred to as a computer layer abstraction. That is why C# is usually
considered a high-level programming language.
Programming at a lower level requires much more knowledge of memory management and a wide
variety of other APIs that might include graphic cards, physics, sound, and everything else that runs a
game. Writing for a layer involves an in-depth knowledge of both the layers below and above the one
you’re writing for.
The computer hardware, such as CPU, graphics card, memory, and storage, live on the lowest level.
Above them is the basic input/output system (BIOS) and software that starts the hardware when you
press the Power button. Above that is your computer’s operating system and drivers that talk to the hard-
ware. Finally, Unity 3D lives above the operating system and your code lives above Unity 3D.
That is why we’re going to use Unity 3D to write games and not start from scratch in raw C++.
Otherwise, we’ll have to spend a few years learning about physics, rendering, and assembly language or
the instruction set that your CPU uses to operate.
• You pay a royalty fee of 20% of the gross profits you derive from
the use of Project Gutenberg™ works calculated using the
method you already use to calculate your applicable taxes. The
fee is owed to the owner of the Project Gutenberg™ trademark,
but he has agreed to donate royalties under this paragraph to
the Project Gutenberg Literary Archive Foundation. Royalty
payments must be paid within 60 days following each date on
which you prepare (or are legally required to prepare) your
periodic tax returns. Royalty payments should be clearly marked
as such and sent to the Project Gutenberg Literary Archive
Foundation at the address specified in Section 4, “Information
about donations to the Project Gutenberg Literary Archive
Foundation.”
• You comply with all other terms of this agreement for free
distribution of Project Gutenberg™ works.
1.F.
1.F.4. Except for the limited right of replacement or refund set forth in
paragraph 1.F.3, this work is provided to you ‘AS-IS’, WITH NO
OTHER WARRANTIES OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO WARRANTIES OF
MERCHANTABILITY OR FITNESS FOR ANY PURPOSE.
Please check the Project Gutenberg web pages for current donation
methods and addresses. Donations are accepted in a number of
other ways including checks, online payments and credit card
donations. To donate, please visit: www.gutenberg.org/donate.
Most people start at our website which has the main PG search
facility: www.gutenberg.org.