Skip to content

HasInstance boolean for unsubscribing from events in OnDisable/OnDestroy#27

Open
my-dimons wants to merge 3 commits into
UnityCommunity:mainfrom
my-dimons:HasInstance-bool
Open

HasInstance boolean for unsubscribing from events in OnDisable/OnDestroy#27
my-dimons wants to merge 3 commits into
UnityCommunity:mainfrom
my-dimons:HasInstance-bool

Conversation

@my-dimons
Copy link
Copy Markdown

Fixes the issue brought up in #17

Changes

  • Added a HasInstance boolean in the MonoSingleton<T> and Singleton<T> scripts.
  • Updated the README.md with a "Common Issues" section which lists why this error happens, and how to fix it

I ran into this error when making my own game using this package and trying to unsubscribe from events. I tried the fix described in the response and it worked, but I saw there was no fix in the project for it. I would have to add it to every script I made if I didn't fix it, so here we are.

my-dimons added 3 commits May 22, 2026 13:50
The HasInstance boolean checks if an instance of the singleton exists without spawning a new singleton.

Fixes an issue with events when trying to unsubscribe in OnDestroy/OnDisable in UnityCommunity#17
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

Successfully merging this pull request may close these issues.

1 participant