mcdonaldduncan / Freebooter

Columbia College Chicago Senior Capstone
4 stars 0 forks source link

Fix Singleton Issues Causing Mass Null Refs #278

Closed mcdonaldduncan closed 1 year ago

mcdonaldduncan commented 1 year ago

Singleton logic checks in awake to see if instance is already instantiated and destroys itself if instance already exists

Some get only properties access the singleton instance before awake, this triggers logic to find the singleton in the scene and assign it.

Since the instance is instantiated before awake, the singleton sees an instance is active and proceeds to destroy itself. Unfortunately, the instance is then null so it creates a fresh copy when next accessed.

Some simple logic to only destroy if instance also is not "this" fixed the issue