UGTK / Toolkit / Component Module / Persistent Component Completed
Persistent Component
Summary
The Persistent Component allowing the component to persist across specific scenes, with controls for maximum instances and destruction if not in persistent scenes.
Content
Modules Dependencies
The Persistent Component module requires the following dependencies:
- Generic Component: Provides the base classes and structure for all components.
Ensure that these dependencies are correctly imported and configured in your project.
Setup
Add the Mn_PersistentComponent component to your GameObject.
This component will manage the persistence of the object across scenes.
How To Use
To use the Persistent Component, follow these steps:
- Set the amount of the same component with same Owner(See Generic Component) that you want to be persistent.
- Set if you want to check in all loaded scenes or only in some specific scenes defined in the Persistent Scenes list.
Test Scene
Testing Scene
Open FirstPersistentScene in the module's Debug/ folder.
What to do, in order:
- Press play in FirstPersistentScene and let the persistent object appear.
- Load SecondPersistentScene and check the object is still there, once.
- Go back to the first scene and look again.
Step 3 is the test that matters. A persistent object that is also placed in the first scene gets created a second time on the way back, and you end up with two — usually noticed much later, as a duplicated manager or a sound playing twice.
The recording is the Hierarchy, which is where this component is visible at all: with the editor
stopped PersistentObject sits inside FirstPersistentScene, and the moment the game starts it
is gone from there and listed under DontDestroyOnLoad instead. Nothing changes on screen -
that is the point of it, and also why it is worth watching the Hierarchy rather than the game.
Technical Info
The Persistent Component is designed to manage the persistence of components across scenes. It provides the following features:
Scripts:
- Mn_PersistentComponent: The main script that manages the persistence of the component.
- Mn_PersistentComponent_Editor: Custom editor for the
Persistent Component, allowing for easy configuration in the Unity Inspector.
© 2026 Marcello De Bonis. All rights reserved
Depends on 1
Used by 1
Measured from the repository: code references (asmdef) plus prefab and asset GUIDs. Importing this module alone brings in 1 module in total.
UGTKengine within an engine


