Skip to content
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

SteamManager destroys itself if the game object has the component two or more times #47

Closed
ellioman opened this issue May 8, 2015 · 1 comment

Comments

@ellioman
Copy link

ellioman commented May 8, 2015

Hey,

Just thought I'd let you know that your singleton approach for the SteamManager has an issue if the game object has more than one instance of the component.

This code:

if (s_instance != null) {
  Destroy(gameObject);
  return;
}

destroys the game object, making the s_instance null.

To prevent this, Unity has a nice class attribute you can add to the script:

[DisallowMultipleComponent]

http://docs.unity3d.com/ScriptReference/DisallowMultipleComponent.html

Of course this is just a minor thing, but I thought I'd share, especially since it's such a simple fix :)

@rlabrecque
Copy link
Owner

This is way late but thanks for sure, I've added this now!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants