How to do it...

To PlayMode and Unit Test a player health bar, follow these steps:

  1. Create a new Unity project, create a new empty scene, and delete the default folder Scenes.
  2. Import the Unity package provided (healthBarScene.unitypackage).
  3. Open the HealthBarScene scene.
  4. Add HealthBarScene to the project Build (menu: File | Build Settings ...).
  5. Display the Test Runner panel by choosing the following menu: Window | General | Test Runner.
  6. Enable PlayMode tests for all assemblies. Do this by displaying the drop-down menu in the top-right corner of the Test Runner panel, and selecting Enable playmode tests for all assemblies (click OK to any message concerned with restarting the editor).
  7. Now restart the Unity Editor (just close the application ...

Get Unity 2018 Cookbook - Third Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.