-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Levels cannot load directly in unity #175
Comments
We can achieve this using OOP. Create a base class that any script that requires incontrol inherits from. Base class has a static boolean variable setupCalled. Base class calls Setup if setupCalled is false and sets it to true so it is only ever called once. |
I agree on OOP, usually the approach for single initialization is the singleton Design Pattern. It's very similar to what you wrote. A class with static member and static property for the instance, so you call that class to get the instance, and on the first call it calls setup. |
I have a way of determining if you have loaded into the level directly or from the main menu: |
Yeah, I don't like hacks. Why is it necessary when we can simply have a singleton object? |
Oh that was just a quick-fix for when I was debugin - I hope there'll be a better way implemented (like what you posted) |
I suggested that @bobsayshilol post his approach so as to have some record what was being used where and what would need replacing/updating when refactoring was happening. |
Issue #171 works but it means it cannot be launched directly. A solution to detect whether setup was called and call if necessary can be useful for local debugging.
The text was updated successfully, but these errors were encountered: