O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Learning Unity iOS Game Development

Book Description

Build exciting games with Unity on iOS and publish them on the App Store

About This Book

  • Take advantage of Unity 5's new tools to create a fully interactive mobile game
  • Learn how to connect your iTunes developer account and use Unity 5 to communicate with it
  • Use your Macintosh computer to publish your game to the App Store

Who This Book Is For

This book is for iOS developers who want to learn how to build games with Unity for the iOS platform. Some prior experience in game development would be useful.

What You Will Learn

  • Create your own iTunes Connect Developer account and create an app within it
  • Set up iTunes Game Center features in iTunes Connect so you can use them within Unity 5
  • Construct a game using C# that allows users to interactively control the game character
  • Use Unity 5's editor window to create a custom editor tool specific for the game made in the book
  • Store and keep track of data so the player is able to collect in-game pick-ups that can be used to purchase in-game goods
  • Use all game features so the player is able to fully navigate menus between the front menu and in the game state
  • Make, test, and finally release builds so you can play on your device and then submit the game to Apple for review

In Detail

Over recent years, the market for mobile game development using Unity has grown multi-fold with an overwhelming 600 million gamers playing games developed using Unity engine. The newly launched Unity 5 offers a wide range of dedicated and powerful tools for iOS developers who intend to follow the basics and gradually elevate their skills to revolutionize the way they design and publish games for the App Store.

From beginners, to those who are experienced making video games, this book goes through the steps of using Unity 5 to make a game from the ground up and setting the game up with iTunes Game Center features.

The book begins with an introduction to setting up an iTunes Connect developer account, this will allow you to use Unity to its full potential with iOS. You will create a new app in iTunes Connect with the settings for Apple approval. You will learn, in detail, how to use Unity 5 and the programming language C# to make a fully interactive game that keeps track of player progress, Game Center Leaderboards, and Achievements, as well as displaying iAds and offering In-App purchases.

Moving on, you'll discover how to create development and release builds, enabling you to test the game on your device before finally submitting the game for Apple's approval.

By the end of the book, you will have a complete understanding of how iTunes and Unity can be used in combination to build and publish a fully interactive and reliable game to the App Store.

Style and approach

This is a step-by-step guide that covers the fundamentals of gaming and reveals the secrets of building and monetizing games for the iOS platform.

Downloading the example code for this book You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the files e-mailed directly to you.

Table of Contents

  1. Learning Unity iOS Game Development
    1. Table of Contents
    2. Learning Unity iOS Game Development
    3. Credits
    4. About the Author
    5. About the Reviewers
    6. www.PacktPub.com
      1. Support files, eBooks, discount offers, and more
        1. Why subscribe?
        2. Free access for Packt account holders
    7. Preface
      1. What this book covers
      2. What you need for this book
      3. Who this book is for
      4. Conventions
      5. Reader feedback
      6. Customer support
        1. Downloading the example code
        2. Downloading the color images of this book
        3. Errata
        4. Piracy
        5. Questions
    8. 1. Requirements and Preparation Work
      1. Requirements
        1. Downloading and installing Unity 5
        2. Installing the iOS SDK plugin
      2. Creating and logging in to the iTunes Connect profile
      3. Creating the Bundle ID and Game App
        1. Setting up App pricing and territories
        2. Creating an in-app purchase
        3. Game Center, leaderboards, and achievements
      4. The Main App settings
        1. Enabling iAds
        2. Setting up iOS Native in Unity
        3. Certificates and provisions on Mac
        4. Why iTunes Connect is important
      5. Summary
    9. 2. Player Input for Mobile Devices
      1. Creating the C# input class
        1. Including system
      2. What is Touch?
        1. Our own Touch
        2. Global variables
      3. Creating the Input GameObject
        1. Calculating the TouchInput function
      4. The Start function
      5. Starting to work with Update
        1. The in-editor input logic
      6. Testing in editor
      7. Input for the Touch device
      8. Wrapping up
      9. Summary
    10. 3. Player Character, Obstacles, and Pickups
      1. What is a character?
      2. What is a pickup?
      3. What is an obstacle?
      4. Creating the character
      5. Creating the character controller
      6. Creating the Character GameObject
      7. Adding Rigidbody 2D
      8. Adding Box Collider 2D
      9. Writing the character code and connecting the PlayerInput class to it
        1. Character attributes
        2. PlayerInput
        3. The KillCharacter function
      10. Creating the coin pickup
      11. Creating the obstacle
      12. Summary
    11. 4. Editor Tool, Prefabs, and Game Level
      1. Making the sprite tile editor tool
        1. The SpriteTiler C# class
        2. Global variables
        3. The MenuItem creation
        4. The OnGUI function
          1. The GUILayout and OnGUI setup
        5. The OnGUI create tiled button
          1. The CreateSpriteTiledGameObject function
          2. Testing the SpriteTiler file
          3. Sprite Tiler wrap-up
      2. The prefab creation
        1. Coin prefabs
        2. Level piece prefabs
        3. Further setup of the level pieces
        4. The level piece code
        5. The level piece manager code
        6. Setting up the LevelPieceManager GameObject
        7. Adding coins and obstacles to LevelPieces
        8. Managing coins and obstacles with the LevelPiece code
          1. Resetting coins
          2. Resetting the coin in LevelPiece
      3. Summary
    12. 5. Scene Background, the Game User Interface, and the Save Profile
      1. Creating the scene background
        1. Adding movement to SceneBackgroundElement
      2. Creating the game user interface
        1. The GameInfo class
        2. Importing UI images
          1. Creating the UI Canvas
            1. The coin background
            2. The distance background
            3. The pause button
          2. Updating code to show coins and distance
            1. Updating the coin class
            2. The restart button
          3. The fade object
            1. The restart functionality
              1. The Awake function
            2. The Update function
            3. The RestartGame function
            4. The RestartLevelAndCharacter function
            5. FadeToBlack and FadeToNormal functions
            6. The HideRestartButton function
          4. The ResetLevelPieces function in LevelPieceManager
            1. Updating Character To Reset
            2. Connecting RestartGame to the RestartButton click
        3. PlayerPrefs game save object
      3. Summary
    13. 6. Main Menu, iAds, Leaderboards, Store Purchases, and Achievements
      1. Building the main menu UI
        1. Adding button images
          1. PlayButton
          2. LeaderboardButton
          3. AchievementButton
          4. RemoveAdsButton
          5. RestorePurchaseButton
          6. The Purchase Remove iAds panel
            1. RemoveAdsBackgroundScreen
            2. RemoveAdsScreen
            3. RemoveAdsTextOption
            4. ForCoin
            5. ForCoinText
            6. ForCash
            7. ForCoinText
            8. CloseRemoveAds
          7. The Purchase Succeeded panel
            1. PurchaseSucceededBackgroundScreen
            2. PurchaseSucceededScreen
            3. PurchaseSucceededText
            4. PurchaseSucceededAccept
            5. PurchaseSucceededAcceptText
            6. PurchaseSucceededClose
          8. The Purchase Failed panel
          9. Connecting the MainMenuUI reference to GameInfo
        2. The menu code
          1. The GameInfo menu code
          2. The LevelPieceManager menu code
          3. The character menu code
          4. Completing changes in Unity
        3. Adding the BackToMenu button in GameUI
        4. Code for leaderboard and achievement buttons
        5. Code for achievements
          1. Game center events
            1. SubmitAchievementProgress
            2. SubmitAchievementAsWhole
          2. SubmitLeaderboardScore
          3. The character achievement code
        6. Displaying iAds
          1. Purchasing remove iAds
          2. New RemoveiAds Purchase for coins
          3. The In App Purchase code
          4. The Purchase RemoveIAds functions
          5. Purchasing buttons
          6. Restoring purchases
      2. Summary
    14. 7. Game Builds and Submission to Apple
      1. Setting up Unity for iOS builds
        1. Creating a test build
        2. Making a release build
        3. Submitting the game to Apple
        4. Congratulations!
      2. What next?
        1. Testing
        2. I want to learn more about programming
      3. I want to create a 3D game
        1. 3D programs
        2. Creating textures
      4. Furthermore
      5. Using the Internet
      6. Summary
    15. Index