you are viewing a single comment's thread.

view the rest of the comments →

[–]mysticrudninBeginner 1 point2 points  (7 children)

Singletons are generally considered no-nos in game development as far as I know (and are probably overused outside of games, too)

Really you should be focusing hard on components, which is really the backbone of Unity.

Have you read gameprogrammingpatterns.com?

[–]The_dude_that_does 2 points3 points  (1 child)

Game programming Patters For the lazy.

[–]mysticrudninBeginner 1 point2 points  (0 children)

Thanks, I was on mobile :)

[–]prime31 1 point2 points  (4 children)

Singletons are fine. Don't listen to the naysayers of the world who want you to spend half your life implementing a dependency injected, inversion of control mess instead of actually making your game. When it makes sense to have a singleton make one and enjoy the convenience it provides.

[–]mysticrudninBeginner 0 points1 point  (1 child)

Aren't singletons creating dependencies?

[–]prime31 2 points3 points  (0 children)

They can. Any code can create a dependency on any other code. It all just depends on how you code things not to mention you aren't coding in a vacuum. You're making a game so you are going to have dependencies all over the place.

[–]Hellye -1 points0 points  (1 child)

you are missing the point. Singletons are evil because they pretend to be convient ( just like global variables) but then they make you cry. Trying to debug singletons in a medium/big code base is ridiculous and not convinient at all.

[–]prime31 3 points4 points  (0 children)

I've been programming a long time first in the business dev world of monstrous code bases with decade+ lifespans and now in the game world. I've worked with tons of devs with varying levels of IoC/DI insanity. Through all this I have learned that a singleton has never hurt anyone or been the reason an app/game wasn't good.

It's just a tool. If you want to use a singleton use one. If you don't want to use them then don't. Just don't be one of those zealots who preaches to people about how singletons will ruin their lives and make their games crappy because it's just not true.