Changes to Unity 5
If you have been working with Unity 4.x and are now starting out in Unity 5.x, there are a few key differences in the way things behave. Here you will find a general overview of the most relevant changes to 2D game development, other than the ones already discussed concerning 2D physics.
Note
The following list does not include all of the new features included in Unity 5 and the Unity 5.3 update. For a complete list, visit http://unity3d.com/unity/whats-new/unity-5.0 and http://blogs.unity3d.com/2015/12/08/unity-5-3-all-new-features-and-more-platforms/.
Licensing
Let's start with the best new feature of Unity 5. In previous versions of Unity, certain features were only available in the Pro version and were blocked in the free version. However, in Unity 5, all features are unlocked and can be enjoyed even by developers using the free version, now named Unity Personal. If a game you create with Unity Personal makes $100k or more, you will have to pay for the professional version.
Component access
Another big change to Unity 5 is the removal of quick property accessors within code. This means that a lot of your code written for Unity 4 will need to be rewritten. For example, the use of .rigidBody2D
and .collider2D
are no longer permissible. However, if you have code in your game from an older version of Unity, you will be shown the following warning:
Selecting I Made a Backup. Go Ahead! will automatically convert all quick property accessors to code containing the GetComponent
function. For example, take the following code that was previously written as:
object.ridgidBody2D.isKinematic=false;
Now the preceding code would now be written as follows:
object.GetComponent<Rigidbody2D>().isKinematic=false;
Note
Make sure you back up your code before selecting, I Made a Backup. Go Ahead! The automatic changes may not be what you expect.
Animator changes
The most glaring difference when you initially start up the Unity 5 Animator will be the inclusion of an Entry node. Unity 5 has now added Entry and Exist nodes to StateMachines (we will discuss state machines in Chapter 8, Encountering Enemies and Running Away). These nodes allow the transition between states machines. For the most part, you animations that were running in Unity 4 should run appropriately in Unity 5, but will include the new Entry node, as shown in the following screenshot:
Audio mixing
Previously, if you had a lot of audio sources in your game, dealing with all of them could be quite a hassle. Unity 5 provide an Audio Mixer asset type that now allows you to adjust all of your audio levels more efficiently, as show in the following screenshot: