In my attempt to develop my first iPhone game, I thought I might use a game engine that will make the process as simple as possible. I started searching the internet for available iPhone game engines and stumbled upon Unity 3D. The games you can produce with Unity seem to look awesome.
I started the download of Unity 3D for the iPhone. Below you will find a link to download Unity 3D iPhone.
For most of you, if you’ve come to this page you may have already downloaded Unity iPhone and are now looking for tutorials to get started developing with Unity. If you’ve already launched Unity and had a look at the interface then you may have already started to become discouraged as it appears very daunting at first look.
As I am developing my very first game I will be posting tutorials so that other people will have a chance to learn. In this first tutorial I will briefly cover the Unity iPhone interface as well as how to set up the correct settings for building for the iPhone so that hopefully you will not run into too much trouble getting started.
Unity iPhone: The Interface
The Unity iPhone interface has 7 sections. Starting with the very top is the toolbar and then on the left top is the scene view and below that you have the game view and below that are the play controls for the game view. To the left of the scene view is the Hierarchy view and below that is the project view. Next to those on the right is the Inspector view. I will be going over each of these views and explain what they are used for. Please also note that this is default layout for Unity iPhone and that you can move the views around as you want.
To the very left of the toolbar, you will see 4 controls. These are called transform tools. The transform tools are used to interact with game objects in the scene view. From left to right they are: The Hand Tool, The Move Tool, The Rotate Tool and the Scale Tool. Clicking on the individual tool activates that tool.
The next section of the toolbar are the Transform Gizmo Toggles. These controls affect the scene view display. You can toggle the handle position to either center or pivot. Center will position the Gizmo at the center of the object’s rendered bounds. Pivot will position the Gizmo at the actual pivot point of a Mesh.
The last control on the toolbar is the Layout control. With the layout control you can choose from a list of pre-designed layouts to use with Unity. They each have their own pros and cons, you will have to pick the one that most suits you. I like to use Tall. You can also create a new layout and save it.
That pretty much covers the toolbar. Hopefully I have explained it well enough for everyone to understand. If there is something I left out please feel free to ask questions. Now on to the Scene View
The Scene View:
The Scene View is used to select and position environments, the player, the camera, enemies and all other GameObjects. Maneuvering and manipulating objects is done via the transform tools on the main toolbar at the very top using the transform tools.
As you can see from the screen shot above and subsequent screen shots, all views have their own tool bar. The Scene View toolbar has 8 different items that can be manipulated they are as follows.
- View Selector – The View Selector as its name implies allows you to select the which view you would like within the current window. You would use this to switch the current window to any of the other available views.
- Draw Mode – Here you have a few options: Textured, Wireframe, Textured & Wireframe and Occlusion
- Render Mode – RGB and Alpha are your 2 options within Render Mode
- Lighting – Enabling Scene Lighting will override the default Scene View lighting with whatever lights you have positioned to create your final light setup.
- FX – Game Overlay will enable items like Skyboxes and GUI Elements in the Scene View.
- Ortho – I haven’t figured out what this control does yet… If anyone has any idea, let me know and I’ll add a description.
- Aspect – This control allows you to set your Scene View aspect ratio. There are some useful pre-defined aspect ratios for both the iPhone and the iPad.
- Layers – This control allows you to toggle on and off layers to show in the scene view.
That concludes the overview of the Scene View. As I said before I am still in the learning stages so I am doing the best I can to get the terminology right. You’ll have to excuse any obvious mistakes.
The Game View:
The Game View is rendered from the Camera(s) in your game. It is representative of your final, published game. You will need to use one or more Cameras to control what the player actually sees when they are playing your game.
The Game View has 5 controls. I will cover each of them below
- View Selector – Just as with the Scene View the View Selector allows you to select the which view you would like within the current window. You would use this to switch the current window to any of the other available views.
- Aspect Ratio – Allows you to preview how your game will look on the chosen device.
- Maximize on Play – This control will maximize the game view to full screen when you press the Play button on the Play controls.
- Gizmos – This will show the gizmos in the game view.
- Stats – This will show some game stats within the game view.
That’s it, all there is to the Game View. Hopefully I haven’t confused anyone too much just yet. We are almost done. Just 3 more views to cover and then I will go over the settings that are required to build your project for Xcode.
The Hierarchy View:
The Hierarchy contains every GameObject in the current Scene. Some of these are direct instances of asset files like 3D models, and others are instances of Prefabs — custom objects that will make up much of your game. You can select and Parent objects in the Hierarchy. As objects are added and removed from the scene, they will appear and disappear from the Hierarchy as well.
The Hierarchy View also has a View Selector that allows you to change the view within the current window as well as a Show Prefab toggle that allows you to show Prefabs.
The Project View:
This is where you store all the assets that make up your game, like scenes, scripts, 3D models, textures, audio files, and Prefabs. If you right-click on any asset in the Project View, you can choose Reveal in Finder to actually see the asset itself in your file system.
Important Note: You should never move project assets around using the OS since this will break any metadata associated with the asset. Always use the Project View to organize your assets.
To add assets to your project, you can drag any file from your OS into the Project View, or use Assets->Import New Asset. Your asset is now ready to be used in your game.
Scenes are also stored in the Project View. Think of these as individual levels. To create a new Scene, use Command-N. To save the current Scene into the Project View, use Command-S.
The Project View also has a View Selector and a Create drop-down that will allow you to Create assets from within Unity such as scripts, prefabs, animations, etc…
The Inspector View:
Games in Unity are made up of multiple GameObjects that contain meshes, scripts, sounds, or other graphical elements like Lights. The Inspector displays detailed information about your currently selected GameObject, including all attached Components and their properties. Here, you modify the functionality of GameObjects in your scene.
Any property that is displayed in the Inspector can be directly modified. Even script variables can be changed without modifying the script itself. You can use the Inspector to change variables at runtime to experiment and find the magic gameplay for your game. In a script, if you define a public variable of an object type (like GameObject or Transform), you can drag and drop a GameObject or Prefab into the Inspector to make the assignment.
Unity iPhone – Xcode Settings
Unity iPhone has some basic settings that need to be set in order for you to build your project properly. Unity will export all of your game content into code that Xcode can understand. When your project finishes building within Unity, a script will auto open Xcode and start the compiling process. For this reason we need to make sure that the information that we would usually put into the info.plist file within Xcode is properly setup within Unity. You can get to the settings by going to Edit -> Project Settings -> Player.
You should at this point be familiar with the settings that need to be set for your Unity app to compile properly within Xcode. If you don’t know what to put into this section then I suggest you spend some time with Xcode and on the Apple Developer site. If anyone needs an explanation for the above settings I will be more then happy to add to this tutorial but I think they are mostly self explanatory.
Well, this concludes the first tutorial for Unity iPhone. I hope you found it useful and please bare with me as I learn my way around this awesome game engine.