If you want to reduce loading times it's a good idea to keep everything lightweight. Unless i'm missing something, passing data between scenes comes down to one of these: global (static) variables, singleton pattern, DontDestroyOnLoad and using PlayerPrefs, or your own way of saving (eg to a file). Thus, if you were to delete this global variable or the entire global class, suddenly some class breaks without being changed. They inherently make things less modular, since classes start to internally work with data that is not actually part of the class. While less convenient, from an architectural viewpoint it's often better to stay away from 'global accessability' such as static global variables or singleton classes. This seems to be similar to what you currently have. When playing a game you would just load the active deck. If you want to stick with the static approach, you could try having an array of 'Decks' in a static DeckManager class, thus having access to all your decks globally, with the active deck being saved as index. However, if you had multiple static instances then you'd need to differentiate between them anyways, meaning you could just as well make them non-static instances that persist between the scenes in some other way. The whole point of 'static' it allows access from outside of instances (anything static is only saved once in memory instead of being saved per instance), so no you cannot create static instances.
0 Comments
Leave a Reply. |