Skip to content
This repository has been archived by the owner on Feb 6, 2024. It is now read-only.

technicat/learnunity

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This is the GitHub repo for the book Learn Unity 4 for iOS Game Development. It includes the Unity projects for each chapter, culminating in the Learn Unity bowling game app.

The republishing rights revert to me after the book goes "out of print" but I don't know if that ever happens these days with on-demand printing. The Apress contract does allow author publication of some excerpts, so I've included the preface and the Explore Further sections at the end of each chapter (slighty updated with link fixes and removal of some obsolete info, like referral to my social media feeds). They are also collected at learnunity.technicat.com.

Javascript/Unityscript is no longer supported by Unity, but the chapter 17 project here has been converted to C# and minimally updated to work with recent versions of Unity (I perform an upgrade time to time). Some Unity APIs are no longer available, e.g. the user interface.

There is an updated version of the book for Unity 2017. I am listed as a co-author (and theoretically I should receive royalties if anyone buys it), but I was not involved in that edition. From what I've seen in a Google Books preview, I believe it's primarily the same material (and unfortunately still Javascript/Unityscript), but with some updates and some content removed (the material on Game Center, my preface and acknowledgments, and my photo - thanks a bunch, Apress).

The Book

Learn Unity 4 for iOS Game Development is available on:

This book introduces Unity starting with installation and activation, learning the interface with the included Angry Bots demo, and then builds up successively more elaborate project examples from scratch and using free assets from the Unity Asset Store. A simple spinning cube and dancing skeleton scene is constructed, but most of the book is devoted to building a 3D bowling game with the control style of HyperBowl. The game is first developed and tested in the Unity Editor, incorporating graphics, scripting (with JavaScript), physics, sound, user interface, complete rules for a bowling game, and mouse controls. The game is then adapted to run on iOS with touchscreen and (a little bit of) accelerometer input. Testing with the Unity Remote, iOS Simulator and real devices is explained, Game Center and iAd integration is covered, and then optimization techniques are described. The book concludes with a brief treatment of miscellaneous topics such as C# scripting, Unity Editor scripting, Android development, and tracking and promoting sales.

Some retail descriptions list Unity's Mecanim animation system. The book does mention but does not use Mecanim. Instead, a chapter is devoted to a dancing skeleton example using Unity's Legacy animation system and a free skeleton package on the Asset Store. Also, some retail descriptions list Unity's support for gyroscope on iOS devices. The book does mention but does not use Unity's gyroscope API (Input.gyroscope). The book does describe how to access the touchscreen (Input.touches), accelerometer (Input.accelerometer), and webcam (WebCamTexture).

Technical review was provided by Marc ShĂĄrer of Gayasoft.

Contents, Clarifications, and Corrections

Page numbers correspond to the print version. Links are provided to the online Unity documentation cited in the Explore Further sections.

About the Author

  • page xxi: Snow Crash should be italicized. And that's by Neal Stephenson, by the way (The Diamond Age is also highly recommended).

Introduction

Explore Further

A full list of Unity books is available at Games from Scratch

Chapter 1 - Getting Started

Download and install Unity, activate the license, report bugs, get help.

  • page 3: "OSX installer package" should read "OS X installer package"
  • page 5: "Script Reference" should read "Scripting Reference"
  • page 5: "Scripts.unityPackage" is one word
  • page 7: Starting with Unity 4.2, he free version of Unity now includes Unity iOS Basic (and Unity Android Basic)
  • page 13: "The 3D game engines are very complicated" should read "3D game engines are very complicated"

Chapter 2 - A Unity Tour

Use the Angry Bots demo to explore the Unity Editor.

  • page 25: "go ahead and buildl an OS X app" should read "go ahead and build an OS X app"

  • page 58: "Console" and "Console view" should read "Console View" (for consistency, we include "View" in the view name and capitalize as in the Unity documentation - think "Eiffel Tower" vs. "Eiffel tower")

  • page 58: "a script calls a Log.LogError" should read "a script calls Debug.LogError"

  • page 58: Starting with Unity 4.1, filtering of Console View messages is controlled by the three buttons at the top right of the view. Tip: make sure that error messages are not filtered.

  • page 60: Starting with Unity 4.2, YAML support (the Force Text option in Editor Settings) is availble in Unity Basic

  • page 60: Starting with Unity 4.2, the Editor has integrated Perforce support and an API for supporting other version control systems.

Explore Further

Chapter 3 - Making a Scene

Create a new Unity scene, add primitive models, textures, lighting, and camera movement. Import assets from Standard Assets, the Unity Asset Store, and the file system. This chapter uses the Free ArtskillZ Texture Pack 01 from ArtskillZ..

  • page 63: "Assets that were installed with Unity in the previous chapter" should read "Assets that were installed with Unity in Chapter 1
  • page 67: "Script Reference" should read "Scripting Reference"
  • page 109: "Building a Scene" should read "Building Scenes"

Explore Further

Chapter 4 - Making it Move: Scripting the Cube

Create a script (JavaScript), spin the cube, make prefabs, edit and debug scripts with MonoDevelop. Also demonstrate tween animation with iTween from Pixel Placement.

Explore Further

Chapter 5 - Let's Dance! Animation and Sound

Import a dancing skeleton and music, select and loop the animation and music, add shadows and particle effects. This chapter uses the Skeletons Pack from bisaniyehocam and General Music Set from Gianmarco Leone.

  • page 164 - Starting with Unity 4.2, dynamic shadows are available in the free version of Unity, but only hard shadows with directional lights, so if you're running Unity free, select Directional for the type of the light and Hard Shadows for the shadow type.

Explore Further

Chapter 6 - Let's Roll! Physics and Controls

Create the beginnings of a bowling game. Make a ball and floor, add colliders and rigidbodies for collision detection and collision reaction, respectively. Uses Eighteen Free Substances from Allegorithmic.

  • page 211 - AddTorque, AddRelativeTorque, AddExplosionForce, AddForceAtPosition should be formatted like the other function names/pages (i.e., in quotes).

Explore Further

Chapter 7 - Let's Bowl! Advanced Physics

Add bowling pins using primitive models and models from the Asset Store. Construct compound colliders. Add sound effects triggered by collision callbacks. Uses the Free SFX Package from Bleep Blop Audio and Barrel from Universal Image.

Explore Further

Chapter 8 - Let's Play! Scripting the Game

Implement the bowling game rules with a finite state machine using coroutines.

Explore Further

Chapter 9 - The Game GUI

Implement a scoreboard and pause menu with UnityGUI. Demonstrates Necromancer GUI from Ironbound Studios.

Explore Further

Another one I forgot to mention:

Chapter 10 - Using Unity iOS

Return to Angry Bots to get familiar with Unity iOS. Switch the build target to iOS, customize Player Settings, test in the Editor with Unity Remote, build to Xcode and test in the iOS Simulator.

Problems introduced with Xcode 5 (hopefully temporary):

  • Build and Run in the Unity Editor fails to start Xcode 5. Workaround: start Xcode manually first, or double-click the xcodeproj file to bring up Xcode 5 manually, then click the Run/Play button.

Chapter 11 - Building For Real: Hardware Testing and App Submission

Set up devices, provisioning profiles and app descriptions on the Provisioning Portal and iTunes Connect. Build Angry Bots for test devices and for submission to the App Store.

Xcode no longer displays provisioning profiiles, and it is no longer necessary (or possible) to install development provisioning profiles on test devices via the Xcode Organizer. The profile is autmatically installed if necessary when running/installing the app.

Problems introduced with Xcode 5 (hopefully temporary):

  • In Xcode 5, Archive may complain there is no matching provisioning profile for the test device. Workaround: detach the test device before invoking Archive.

Chapter 12 - Presentation: Icons and Splash Screens

Resume work on the bowling game. Automatically scale the GUI for different screen sizes. Incorporate initial and secondary splash screens.

It should be noted the Fugu Games splash screen and the Fugu icon (also used as a texture in Chapter 3) are based on the Fugu Games logo designed by Shane Nakamura.

  • page 390: The x and y values specifying the normalized screen coordinates of the GUITexture are entered in the Transform Component's position.

Explore Further

Books

Chapter 13 - Device Input

Implement touchscreen input for the bowling game, detect shakes with the accelerometer, display video textures with the webcam.

  • (page 407) Starting with Unity 4.5, the Camera far property has been renamed farClipPlane.

Explore Further

Chapter 14 - Game Center: Leaderboards and Achievements

Set up Game Center leaderboards and achievements in iTunes Connect. Submit high scores and achievements and activate iOS5-style achievement banners with scripts.

Explore Further

Chapter 15 - iAd: Banner and Interstitial Ads

Set up iAd in iTunes Connect. Add a banner ad and intersitiai ad to the bowling game with scripts.

  • page 443: In "The while loop calls yield", "yield" should be formatted as inline code
  • page 443: "the ad will immediately display by with a call to" should read "the ad will immediately display with a call to"
  • page 443: "which will show up as check boxes" should read "which will show up as checkboxes"
  • page 447: "the static variable of iPhone.generation" should read "the static variable iPhone.generation"

Apple has since discontinued iAd, so there is no longer a scripting interface. There are other ad services with Unity script interfaces, including Unity's own Unity Ads.

Chapter 16 - Optimization

Optimize for quality, space and speed (just not all at once). Use the Editor and built-in profilers.

  • page 474: "Inspector view" should read "Inspector View"
  • page 496: "Player Settings" should not be quoted (not a reference to a Unity Manual page)
  • page 496 "Automatic Memory Management" should read "Understanding Automatic Memory Management"

Explore Further

Chapter 17 - Where to Go from Here?

Miscellaneous topics: C# and Editor scripts, plugins, customizing script execution order, promoting your apps, more monetization.

  • page 512: "Storekit" should read "StoreKit" as in the Prime31 documentation (or "Store Kit" as in the Apple documentation)
  • page 513: "not available on Android either" should just read "not available on Android"
  • page 513: There should be a paragraph break after "Twitter, by the way, is another great way to interact with other Unity developers, on a more personal level."
  • page 513: Of course, the UNITY_IPHONE preprocessor definition is not active when the build target is Android. Use UNITY_ANDROID instead (or in addition). Unlike iOS, Android apps conventionally have a Quit button and Android devices have a Back button that is recognized by Unity as the Escape key. The GitHub project for this chapter includes those Android-specific changes in the pause menu. Backing up the assertion that the code in this book works on Android, the Learn Unity app is available on Google Play and the Amazon Appstore, and for the Nook and the Nabi tablets.

Back Cover

  • "Three-dimensional games" should read "3D games" (no one says "three-dimensional glasses" or "three-dimensional movies")

Ebooks

All Versions

  • Many of the quoted titles in the Explore Further sections should be links to online documentation (for the Scripting Reference pages, try searching for those terms in the Scripting Reference search box).

iBook

No problems that I can see.

Kindle

  • Figure links don't always work.
  • There is a second Kindle edition with a publication date of August 4. I don't know what's different about it except it's been reported that the full table of contents (not the Contents at a Glance) has broken links.

Nook

  • URL's display with markup and are not active as links (you can check the sample to see if it's been fixed.

The Code

The GitHub projects, built up cumulatively through each chapter to create a bowling game similar in style to HyperBowl, do not include assets from the Unity Asset Store and Standard Assets that are used in the book, but you can use them a starting point or to save time in constructing the book examples (but taking shortcuts isn't really recommended). The projects require Unity 4.2 or later and are covered under the MIT open source license.

The App

The app is currently unpublished on the App Store but available as desktop, web, and Android builds on itch.io