All-in-One Solution for Indie Game Development · Empowering Indie Developers' Dreams
Documentation · Quick Start · QQ Group: 467608841 / 233840761
Game Frame X Mono is a Mono lifecycle component for the GameFrameX framework. It manages MonoBehaviour events and update cycles in games, such as FixedUpdate, LateUpdate, OnDestroy, etc., and provides a convenient way to add and remove event listeners.
Choose one of the following methods:
-
Edit your Unity project's
Packages/manifest.jsonand add thescopedRegistriessection:{ "scopedRegistries": [ { "name": "GameFrameX", "url": "https://gameframex.upm.alianblank.uk", "scopes": [ "com.gameframex" ] } ], "dependencies": { "com.gameframex.unity.mono": "1.1.3" } }scopescontrols which packages are resolved through this registry. Only packages whose names start withcom.gameframexwill be fetched from it. -
Add to
manifest.jsondependencies:{ "com.gameframex.unity.mono": "https://github.com/gameframex/com.gameframex.unity.mono.git" } -
Use Package Manager in Unity with Git URL:
https://github.com/gameframex/com.gameframex.unity.mono.git -
Clone the repository into your Unity project's
Packagesdirectory. It will be loaded automatically.
var monoComponent = GameEntry.GetComponent<MonoComponent>();MonoComponent allows registering callbacks for Unity's MonoBehaviour lifecycle events. All listeners can be added or removed at any time.
These three listeners receive two float parameters:
elapseSeconds— scaled delta timerealElapseSeconds— unscaled delta time
private void OnUpdate(float elapseSeconds, float realElapseSeconds)
{
// Called every frame
}
private void OnFixedUpdate(float elapseSeconds, float realElapseSeconds)
{
// Called at fixed intervals (physics)
}
private void OnLateUpdate(float elapseSeconds, float realElapseSeconds)
{
// Called after all Update calls
}
// Register
monoComponent.AddUpdateListener(OnUpdate);
monoComponent.AddFixedUpdateListener(OnFixedUpdate);
monoComponent.AddLateUpdateListener(OnLateUpdate);
// Unregister when no longer needed
monoComponent.RemoveUpdateListener(OnUpdate);
monoComponent.RemoveFixedUpdateListener(OnFixedUpdate);
monoComponent.RemoveLateUpdateListener(OnLateUpdate);private void OnDestroyCallback()
{
// Called when the MonoComponent's GameObject is destroyed
}
monoComponent.AddDestroyListener(OnDestroyCallback);
monoComponent.RemoveDestroyListener(OnDestroyCallback);These listeners receive a bool parameter and support a dual notification pattern — you can use either direct listeners or the event bus.
Direct listener approach:
private void OnApplicationFocus(bool isFocus)
{
// isFocus: true = app gained focus, false = lost focus
}
private void OnApplicationPause(bool isPause)
{
// isPause: true = app paused, false = resumed
}
monoComponent.AddOnApplicationFocusListener(OnApplicationFocus);
monoComponent.AddOnApplicationPauseListener(OnApplicationPause);
monoComponent.RemoveOnApplicationFocusListener(OnApplicationFocus);
monoComponent.RemoveOnApplicationPauseListener(OnApplicationPause);Event bus approach (via EventComponent):
var eventComponent = GameEntry.GetComponent<EventComponent>();
eventComponent.Subscribe(OnApplicationFocusChangedEventArgs.EventId, OnFocusChanged);
eventComponent.Subscribe(OnApplicationPauseChangedEventArgs.EventId, OnPauseChanged);
private void OnFocusChanged(object sender, GameEventArgs e)
{
var args = (OnApplicationFocusChangedEventArgs)e;
if (args.IsFocus)
{
// App gained focus
}
}
private void OnPauseChanged(object sender, GameEventArgs e)
{
var args = (OnApplicationPauseChangedEventArgs)e;
if (args.IsPause)
{
// App paused
}
}- Listener registration is thread-safe.
- Listeners can safely add or remove other listeners during callback invocation (snapshot dispatch).
- Exceptions in callbacks are caught and logged, and do not interrupt other listeners.
- Always unregister listeners when no longer needed to avoid memory leaks.
- Documentation: https://gameframex.doc.alianblank.com
- Repository: https://github.com/GameFrameX/com.gameframex.unity.mono
- Issues: https://github.com/GameFrameX/com.gameframex.unity.mono/issues
| Package | Description |
|---|---|
com.gameframex.unity.event |
1.1.0 |
- QQ Group: 467608841 / 233840761
See Releases for changelog.
See LICENSE for details.