UnityCommunity / UnitySingleton

The best way to implement singleton pattern in Unity.
https://en.wikipedia.org/wiki/Singleton_pattern
MIT License
458 stars 61 forks source link

Scene Singleton Pattern #5

Closed starryforest-ymxk closed 11 months ago

starryforest-ymxk commented 11 months ago

In some cases we should use this pattern, it differs from the traditional "Global singleton pattern", the purpose of "Scene Singleton Pattern" is to ensure that there is only one instance of the class in a given scene, but it does not require that instance to persist across scenes. This pattern is useful when you need to manage certain assets or features in a single scene, but you don't want those assets or features to remain present when the scene is switched.