binocularsScene Architecture and Zenject Setup

Path to scenes: Assets/StaticAssets/Scenes...

Bootstrap

  1. SceneContext is the entry point for Zenject in the Bootstrap scene. Even if it doesn’t install anything itself, its presence is necessary to:

  • Initialize the scene with dependencies;

  • Enable injection through the Context into objects of this scene;

  • Synchronize operation with ProjectContext;

  • Ensure the DiContainer works within the scene.

  1. Bootstrapper is a component that performs the key function of launching the entire system through a State Machine.


In addition, the ProjectContext is created.

ProjectContext is a global (singleton) container that:

  • initializes once at project start (in the Bootstrap scene);

  • persists between scenes (is not destroyed on scene change);

  • contains global dependencies accessible in all scenes (e.g., GameManager, AudioManager, Config, etc.);

  • is created from a prefab located in the Assets/Resources/… folder.

The source code and documentation for Extenject can be found here:

Level

  1. The SceneContext object in the Level scene serves as the main integration point for Zenject within the context of that scene. The MonoInstaller (GameplayInstaller.cs) is added to the SceneContext.

  • What GameplayInstaller does:

    • Registers game services and managers required within the Level scene.

    • Serves as the sole (or primary) place for configuring level dependencies.

  1. GameplayBootstrapper is a component that launches the gameplay state machine in the Level scene. It serves as a local entry point for the state management system specifically related to gameplay (as opposed to the Bootstrapper, which operates during the project's initialization phase).

  2. The CameraContext object groups all cameras used in the Level scene. Note the MainCamera object containing the PhysicsRaycaster component. The MainCamera inside CameraContext has a PhysicsRaycaster component, which is necessary for UI interaction with 3D objects via events (e.g., OnPointerClick, OnDrag, etc.).

For the player upgrade system using drag'n'drop to work properly, the Event Mask field of the PhysicsRaycaster component must include the layers: Player and Part.

  1. The HUD object collects and provides access to visual interface elements during gameplay. It is used by other systems (e.g., shooting, upgrading, balancing) to display the current state.

  1. Screens is a pre-created container where all window objects are added as child elements. These objects are not initially in the scene hierarchy but are created dynamically upon first access.

  2. [Global] AudioManager is a global sound manager designed for centralized audio playback in the Level scene. When the scene starts, it is registered in the Zenject container, allowing any services and components to access it via dependency injection (DI).

Last updated