03. Demo Scene

  02. Installation No Comments

The project comes with a demo scene containing a simple game showcasing many of the features offered by Init(args). It acts as an example of a very flexible and easily unit-testable architecture that can scale well to drive large projects as well.

Installing Dependencies

Before installing the demo scene you must first install the Unity UI and Test Framework packages.

To install the packages perform the following steps:

  1. Open the Package Manager using the main menu item Window > Package Manager.
  2. Click the second dropdown menu on the top bar and select All packages.
  3. Find the Test Framework package in the list and select it.
  4. Click the Install button and wait until the package has finished installing.
  5. Next find the Unity UI package in the list and select it.
  6. Click the Install button and wait until this package has also finished installing.

If you do not care to see the unit tests for the demo project, you can also skip installing the Test Framework package, and then untick the folder Assets/Sisus/Init(args)/Demo/Tests during installation of the Demo package.

Installing The Demo

To install the demo project perform the following steps:

  1. locate the unity package at Assets/Sisus/Init(args)/Demo Installer in the Project view and double-click it.
  2. In the Import Unity Package dialog that opens select Import.

After installation has finished you can find the demo scene at Assets/Sisus/Init(args)/Demo/Demo. To try out the demo open the Demo Scene and enter play mode.


You control the yellow cube using the arrow keys and your objective is to collect as many green dots as you can without hitting any of the red cubes.

Scene Overview

The Demo has been split into four subscenes. This has been done to showcase how Init(args) can help enable a multi-scene workflow, which can help reduce the amount of conflicts that occur when multiple people working on the game at the same time.

  1. Demo: The main scene just contains the Subscenes Load Handler which is responsible for loading all the other subscenes both in edit mode as well as play mode.
  2. Demo.Level: Contains the camera, lighting as well as the GameObjects that make up the level.
  3. Demo.Entities: Contains the Player object and two spawner objects responsible for creating collectables and enemies during gameplay.
  4. Demo.UI: Contains the user interface for the game as well as the Reset Handler.

Some of the important objects in the demo include:

  1. Level: The Level component defines the bounds of the level inside which the player can move and enemies and collectables can spawn. The class is also a service to make it more convenient for other objects to retrieve a reference to it. Nested underneath the GameObject are also the visual elements that make up the level.
  2. Player: Contains the Player, Movable and Killable components. The Player component is responsible for detecting collisions with ICollectable object and the Killable component with IDeadly objects. The Movable component is responsible for moving the GameObject within the bounds of the level and is driven by the OnMoveInputChanged component.
  3. Enemy Spawner: Contains the SpawnerInitializer which is used to specify the arguments for the SpawnerComponent. The SpawnerComponent is created at runtime, and is actually just a simple wrapper for the Spawner, a plain old C# object, which actually holds all the logic for spawning the enemies.
  4. Collectable Spawner: Just like Enemy Spawner except configured to spawn instances of the Collectable prefab instead of enemies.
  5. Reset Handler: Houses the ResetHandler component which is used to reset the game state when the player presses the ’R’ key.
  6. UI: Contains the Score and Game Over texts. The Score texts has been hooked to update when the On Collected event is invoked and the Game Over text has been hooked to become active when the On Player Killed event is invoked. The events are represented by scriptable object assets, so that objects in different scenes can reference it. The events are also services, so that instances of the event triggers On Collected and On Player Killed can be used without needing to manually drag-and-drop a reference to the event asset. Both events also implement an interface which can be passed to clients to allow them to subscribe to the event and unsubscribe from it, but not trigger it, for better encapsulation.

All classes in the demo have XML documentation comments, and the best way to learn more about the demo project is to go examine its source code.

The demo also contains a number of unit tests to showcase how Init(args) can help make your code more easily unit testable. The tests contain some interesting patterns such as testing of coroutines in edit mode and suppression of logging for the duration of the tests.

Leave a Reply

Your email address will not be published. Required fields are marked *