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

Fixed NullReferenceException in WorldBrowserWindow #240

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Burrik
Copy link

@Burrik Burrik commented Feb 12, 2025

Description

Fixed NullReferenceException in WorldBrowserWindow after script recompilation in Play Mode.

Problem

When scripts are recompiled in Play Mode:

  1. All fields in WorldBrowserWindow are reset to null
  2. Update() continues to be called
  3. This causes NullReferenceException when trying to access null fields

Solution

Improved null-checks in Update() method:

  1. Added early return if not initialized
  2. Added componentsStorage null check
  3. Reset initialized flag if componentsStorage is null
  4. Removed redundant checks and simplified the code

How to Test

  1. Open World Browser window
  2. Enter Play Mode
  3. Make any script change to trigger recompilation
  4. Verify that:
    • No NullReferenceException occurs
    • Window properly reinitializes after recompilation
    • All functionality works correctly

Before Fix

NullReferenceException occurs after script recompilation:
NullReferenceException: Object reference not set to an instance of an object
Scellecs.Morpeh.Utils.Editor.WorldBrowserWindow.Update()

After Fix

  • No exceptions after recompilation
  • Window gracefully handles null states
  • Properly reinitializes when needed

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