GSIBase
Coding Style wiki
using OxGFrame.GSIFrame;
Core Design Concept
GSIBase defines a complete lifecycle for a game stage. Through the automated process of BeginInit, it ensures that stages execute in the order of "Stop Updating -> Perform Initialization -> Start Updating" when entered, supporting asynchronous processing (UniTask).
Properties and States
- id
- Type:
int - Description: Unique identifier for the stage, automatically assigned when registered by
GSIManager.
- Type:
- runUpdate
- Type:
bool - Description: Switch that controls whether
OnUpdatefor this stage is executed.
- Type:
Built-in Flow Control
Execution Order Description
- First Check: If not yet initialized, execute
OnCreate(initialized only once). - Step 1: Call
StopUpdate()to pause refreshing. - Step 2: Call
OnEnter()for asynchronous initialization logic of this stage. - Step 3: Call
RunUpdate()to startOnUpdaterefreshing.
Must Implement Methods (Implementation)
After inheriting from GSIBase, the following lifecycle methods must be implemented:
OnCreate()
- Return Value:
UniTask - Trigger Timing: When the stage instance is switched to for the "first" time.
- Purpose: Suitable for one-time resource preloading or object initialization.
OnEnter()
- Return Value:
UniTask - Trigger Timing: Every time the stage is switched to.
- Purpose: Handle logic when entering the stage, such as opening UI windows or playing transition animations.
OnUpdate(float dt)
- Return Value:
void - Trigger Timing: When
runUpdateis true and the stage is active, refreshes with the game frame rate. - Purpose: Handle cyclic logic within the stage (such as timers, character control, etc.).
OnExit()
- Return Value:
void - Trigger Timing: Before switching to the next stage.
- Purpose: Clean up temporary data generated in this stage, close related UI, or stop sound effects.
Stage State Operation
Developers can manually control update behavior within the stage using the following methods:
- RunUpdate(): Manually start
OnUpdateexecution. - StopUpdate(): Manually pause
OnUpdateexecution.
Reminder Since OnCreate and OnEnter support UniTask, you can conveniently use await in these methods to wait for resource loading to complete. The system will automatically start OnUpdate after the loading is finished.