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

Multiple copies of the UnityMainThreadDispatcher #1

Closed
mbger opened this issue Apr 26, 2016 · 3 comments
Closed

Multiple copies of the UnityMainThreadDispatcher #1

mbger opened this issue Apr 26, 2016 · 3 comments

Comments

@mbger
Copy link

mbger commented Apr 26, 2016

Hi,

I came across this when I searched for some sort of Singleton gameobject pattern which is persistent across scenes. I implemented it just the way you did, but had the problem that my object was created several times when I switched back and forth between scenes. After reading this I ended up removing the OnDestroyed()-method which clears the _instance field and added this to the Awake-method:
`void Awake () {

    if (_instance == null) {
        _instance = this;
        DontDestroyOnLoad (this.gameObject);
        //...
    } else {
        Destroy (this.gameObject);
    }
}`

Maybe this is an issue for you, too (frankly, I don't know why the OnDestroy()-method was called on my gameobject)

@PimDeWitte
Copy link
Owner

Thank you for this. Adding it and pushing the new version. Sorry fo the inconvenience!

@PimDeWitte
Copy link
Owner

Fixed this in ae76667

@sebastiangug
Copy link

Hi - I seem to be getting the same behaviour using the latest version here on github, not sure which part of it makes it do this. Here's a screenshot after loading between a few scenes -- showing multiple instances of that object: https://i.imgur.com/1qaXJQH.png

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

3 participants