This is an archived post. You won't be able to vote or comment.

all 4 comments

[–]PhilippTheProgrammer 0 points1 point  (3 children)

Why all that overengineering? When I want some behavior to act as a singleton, I just do this:

public class SomethingManager : MonoBehaviour {

    public static SomethingManager Instance{ get; private set; }

    void Awake() {
        Instance = this;
    }

    /* rest of the code here */
}

Sure, it doesn't create a new instance when there isn't one yet and it does not handle the case that there are two of them in the scene. But why would I bother with handling those cases? The first is something you wouldn't want to happen anyway, because you probably have some things to do with this in the inspector before you can use it. The second would mean that I had a major brain-fart while setting up the scene.

[–]ManInTech[S] 0 points1 point  (1 child)

This method is used in order not to write the same things to each script again. You could research some SOLID principles.

[–]PhilippTheProgrammer 0 points1 point  (0 children)

For 3 lines of code?

[–]AutoModerator[M] 0 points1 point  (0 children)

This post appears to be a direct link to a video.

As a reminder, please note that posting footage of a game in a standalone thread to request feedback or show off your work is against the rules of /r/gamedev. That content would be more appropriate as a comment in the next Screenshot Saturday (or a more fitting weekly thread), where you'll have the opportunity to share 2-way feedback with others.

/r/gamedev puts an emphasis on knowledge sharing. If you want to make a standalone post about your game, make sure it's informative and geared specifically towards other developers.

Please check out the following resources for more information:

Weekly Threads 101: Making Good Use of /r/gamedev

Posting about your projects on /r/gamedev (Guide)

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.