feat: Merge upstream#5
Merged
Merged
Conversation
- also auto-selects one upgrade, and can now confirm with spacebar on keyboard too
Comment on lines
+49
to
+57
| public static DemoConfiguration Load() | ||
| { | ||
| if (_instance == null) | ||
| { | ||
| _instance = Resources.Load("DemoConfig") as DemoConfiguration; | ||
| _instance?.ApplyRuntimeOverrides(); | ||
| } | ||
| return _instance; | ||
| } |
There was a problem hiding this comment.
Bug: The static DemoConfiguration singleton doesn't clear its _instance on destroy. Scene transitions using LoadSceneMode.Single can cause it to hold a dangling reference to a destroyed object.
Severity: HIGH
Suggested Fix
Implement an OnDestroy() method in DemoConfiguration.cs. Inside this method, check if the current instance _instance is the one being destroyed, and if so, set the static _instance field to null. This ensures that the singleton is properly re-initialized after a scene unload.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.
Location: Assets/Scripts/Config/DemoConfiguration.cs#L49-L57
Potential issue: The static `DemoConfiguration` singleton loads a ScriptableObject into
a static `_instance` field but lacks an `OnDestroy` method to nullify this field. When a
scene transition occurs using `LoadSceneMode.Single`, Unity unloads unused assets,
including the `DemoConfiguration` object. Because the static `_instance` reference is
not cleared, subsequent calls to `DemoConfiguration.Load()` in a new scene will
incorrectly return the stale reference to the destroyed object. Accessing any properties
on this returned object will result in a `UnityEngine.MissingReferenceException`,
causing a crash.
Did we get this right? 👍 / 👎 to inform future reviews.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pulling the latest and greatest from
getsentry/sentaur-survivorsand updating the demo to run from a commandline argument.