-
Notifications
You must be signed in to change notification settings - Fork 0
Overview
The Core module contains the fundamental architecture of the framework. It defines the key concepts, base structures, and core keywords used to build systems within RealMethod. This layer forms the foundation that the rest of the framework is built upon.
Core module have some elements that work together to manage the game lifecycle, scenes, and global systems in a structured way.The main concepts in the Core module are: Game, World, GameManager, Service, GameConfig, and GameBridge
Is the central and global class of the RealMethod architecture. A single instance of this class is created when the game starts on the target platform and remains alive until the application is closed.
Because of this, the Game instance is always loaded in memory and is responsible for controlling high-level game operations such as:
- Opening or changing scenes
- Quitting the game
- Accessing managers
- Coordinating global systems
The
Gameclass acts as the main entry point for interacting with the framework during runtime.
How To Use
- Create a custom
Gameclass:- In the Unity Project window, click the Add (+) buttonor right‑click inside the Project window.
- Navigate to:Create → Scripting → RealMethod → Essential → Game
- Choose a name for your
Gameclass (for example: MyGame).
- Assigning the Game Class:
- Open ProjectSettings in Unity.
- Navigate to RealMethod.
- In the GameClass field, select your newly created
Gameclass.
Once selected, RealMethod will use this class when the game starts.
Note: Creating a custom Game class is optional. If you prefer, you can skip this step and use the built‑in
DefaultGameclass provided by RealMethod. This is useful for quick setups or simple projects where custom global logic is not required.
Represents a scene-level controller. Each Unity scene should contain one World instance (or a class that inherits from World). The World class is responsible for controlling and initializing the scene environment. Its responsibilities typically include:
- Preparing the scene when it loads
- Spawning or setting up the player
- Initializing scene-specific systems
- Managing objects that belong to that scene
In simple terms, while Game controls the application, World controls the current scene.
Note: If you have two world component in scene realmethod automaticly desable second one
How To Use
- Create a custom
Worldclass:- In the Unity Project window, click the Add (+) button or right‑click inside the Project window.
- Navigate to:Create → Scripting → RealMethod → Essential → World
- Choose a name for your
Worldclass (for example: GamePlayWorld).
- Assigning the World Class:
- In the Unity Hierarchy window, click the Add (+) button or right‑click inside the Project window.
- Create Empty GameObjcet
- Add Your Custom World as Component in GameObject
- Commonly you change GameObject name to World
Note: Creating a custom World class is optional. If you prefer, you can skip this step and use the built‑in
DefaultWorldclass provided by RealMethod. This is useful for quick setups or simple projects where custom global logic is not required.
For fast setup just click the Add (+) button and navigate to:RealMethod → Essential → World in Hierarchy
IGameManager is an interface with three method that allows any MonoBehaviour to be registered as a manager within the RealMethod architecture.
GameManagers can be accessed globally through the Game class using:
Game.FindManager<T>()
GameManagers are initialized by the RealMethod lifecycle, which runs before Unity’s standard MonoBehaviour lifecycle(Awake,....) methods. Because of this, managers are not meant to be spawned dynamically in the scene. Instead, they are configured and initialized by the framework.
A key feature of GameManager is that managers can exist in two different scopes(Game,World), that developer decide to chose one.
-
GameScope Managers in
GameScopeare set beside theGameClass and developer can do this withStartPrefabsand these managers likeGameremain alive until the game closes. These managers handle systems that must persist across all scenes Examples:- SaveManager (handles loading and saving game data)
- MusicManager (controls background music across the entire game)
- ScreenManager (all screens between loading scenes or others)
-
WorldScope Managers with
WorldScopeexist only while a specific scene (World) is active. When the scene changes, these managers are destroyed and recreated for the new scene, Developer with added these manager inGameObjectincludeWorldclass can add Manager in WorldScope. Examples:- HUDManager (controls UI elements specific to a level)
- SoundManager (handles scene-based sound effects)
GameScope: Add GameManager Componet in StartPrefabs(We explain is below) WorldScope: Add GameManger Component in World GameObject or Chiled
How To Use
- Create new Manager:
- In the Unity Project window, click the Add (+) button or right‑click inside the Project window.
- Navigate to:Create → Scripting → RealMethod → Manager → BaseManager
- Choose a name for your
GameManagerclass (for example: EnemyManager). OR - Open You any
Monobehaviorscript - Implement
IGameManagerInterface into your class.
- Add In scope for initiateing in game
- Define you wnat your manager always loaded or just useful for target scene
- Add your Manager component beside World component for
WorldScopeor in StartPrefab forGameScope
The Service class in RealMethod represents a lightweight runtime object designed purely for programmatic use — it has no visual or serialized representation in the Unity Editor.
Services are created and destroyed dynamically during gameplay, and their lifecycle is fully managed by the programmer, giving total flexibility over when and how they exist.
Created:
Game.AddService<T>(object author)
Removed:
Game.RemoveService<T>();
Whenever a service is created or destroyed, all managers that implement the GameManager interface are automatically notified. This communication allows managers to adapt their behavior based on available services.
Use Case Example Imagine a MusicManager that adjusts game music depending on the current game state. When a GameStateService is created, the MusicManager detects this and begins playing the track that corresponds to the current state. If the service is removed, the manager can stop or change its behavior accordingly.
You can even create a Service with DirectorService name that stores and updates gameplay data such as difficulty or global parameters across scenes
Relation Between Manager and Service During the initialization phase, any manager can verify if a service exists before performing its setup using:
Game.TryFindService<T>(out T service);
This method lets managers adapt their initial behavior depending on which services are active, enhancing modularity and making RealMethod’s architecture highly responsive and flexible.
Example:
public class MyCustomManager : MonoBehaviour, IGameManager
{
// Implement IGameManager Interface
MonoBehaviour IGameManager.GetManagerClass()
{
return this;
}
void IGameManager.InitiateManager(bool alwaysLoaded)
{
if(Game.TryFindService(out MyCustomService service))
{
DoSomting();
}
}
void IGameManager.ResolveService(Service service, bool active)
{
if(active)
{
if(service is MyCustomService)
{
DoSomting();
}
}
}
}
How To Use
- Create new Service:
- In the Unity Project window, click the Add (+) button or right‑click inside the Project window.
- Navigate to:Create → Scripting → RealMethod → Service → BaseService
- Choose a name for your
Serviceclass (for example: Director).
- Active your Service:
- Any time you need you can use
Game.AddService<>()to create service instance and notify to all manager - Any time you need you can use
Game.RemoveService<>()to notify to all manager and remove service instance
- Any time you need you can use
GameConfig is a ConfigAsset used by RealMethod to store global, designer‑driven data.
Technically, GameConfig is a ScriptableObject, but for now it is enough to know that it is a read‑only configuration asset.
GameConfig loaded automatically when Game initializes.
You can be accessed globally via:
Game.Config
Purpose
GameConfig is intended to hold data that designers may need to tweak, without changing code.
Because it is read‑only at runtime, it provides a safe and predictable way to define game‑wide parameters.
Typical use cases include:
- Difficulty parameters
- Global balance values
- Feature toggles
- References to other configuration assets
Example:
If your game supports multiple difficulty levels, you can implement difficulty‑related parameters (such as enemy health multipliers, damage scaling, or spawn rates) inside your GameConfig.
Designers can then create different GameConfig assets for test each difficulty.
You can't change GameConfig at runtime. A GameConfig asset can also reference other configuration assets or data objects, making it easy to organize complex configuration setups in a modular way.
This approach keeps gameplay logic clean while giving designers full control over tunable game data, all centralized in a single, globally accessible configuration system.
How To Use
- Create Custom GameConfig Class:
- In the Unity Project window, click the Add (+) button or right‑click inside the Project window.
- Navigate to:Create → Scripting → RealMethod → Asset → Config → GameConfig
- Choose a name for your
GameConfigclass (for example: MyGameConfigAsset).
- Create your GameConfig Asset:
- In your script top of class these is
CreateAssetMenumacro inmenunamesection you can address that to create Asset content.
- In your script top of class these is
- Assigning the GameConfgi Asset:
- Open ProjectSettings in Unity.
- Navigate to RealMethod.
- In the GameConfig field, select your newly created
GameConfigasset.
GameBridge is the class responsible for handling the relationship between the Game and World classes, as well as managing scene loading within the RealMethod framework.
A single instance of GameBridge is created after the game starts and remains alive until the application closes. It acts as the central coordinator for scene transitions and world activation.
Game ↔ World Connection
When a World is connected to the Game, RealMethod takes control of how Worlds are activated with GameBridge.
If a new World is detected in a loaded scene, RealMethod automatically disables it by default. This ensures that scene activation is always managed through RealMethod’s lifecycle rather than Unity’s default behavior.
Because of this, RealMethod uses its own scene‑loading approach instead of relying directly on Unity’s standard flow.
Scene Loading Strategy
By default, RealMethod:
- Unloads the current scene
- Loads the new scene
- Displays a loading screen to the player (With
ScreenManager)
A loading screen can be implemented using a ScreenManager (or your custom Manager) registered in GameScope, ensuring it persists across scene transitions.
This controlled process guarantees consistent world initialization and clean transitions between scenes.
Customization and Extensibility
If you want to change how the Game and World interact, customize scene loading behavior, or integrate a third‑party scene management package, you can extend or replace the GameBridge implementation.
By customizing GameBridge, you can define:
- How Worlds become active
- How scenes are loaded or unloaded
- Whether scenes are loaded additively or replaced
- How loading screens or transitions are handled
Scenes can be opened or added through the Game class:
OpenScene(int sceneIndex)
OpenScene(SceneReference scene)
OpenScene(string sceneName)
OpenWorld(WorldSceneConfig WorldScene)
ReOpenScene()
AddScene(int sceneIndex)
AddScene(SceneReference scene)
AddScene(string sceneName)
These methods internally call the corresponding logic inside the GameBridge class, keeping scene management centralized and consistent across the framework.
SceneReference & WorldSceneConfig it will be explained later.
How To Use
- Create Custom GameConfig Class:
- In the Unity Project window, click the Add (+) button or right‑click inside the Project window.
- Navigate to:Create → Scripting → RealMethod → Essential → GameBridge
- Choose a name for your
GameBridgeclass (for example: MyBridge).
- Assigning the GameBridge Class:
- Open ProjectSettings in Unity.
- Navigate to RealMethod.
- In the GameBridge field, select your newly created
GameBridgeclass.
RootA ChildA SubChildA RootB ChildB