Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question NullReferenceException Error

Discussion in 'Editor & General Support' started by Alex123Gaming, Aug 9, 2023.

  1. Alex123Gaming

    Alex123Gaming

    Joined:
    May 15, 2016
    Posts:
    2
    I'm not sure what this error really is, nor why I'm getting it or how to fix it. It doesn't seem to prevent me from doing anything, everything in my project works as intended, but as soon as I start the game, I get the error in the console. It just started happening out of seemingly nowhere as well, which is odd.

    I thought it was because I had a script needing to point to an object and not having actually set it to point to anything, but I triple checked all my objects and their attached scripts, and that's not the case.

    Am currently using Unity 2022.3.6f1 if that changes anything, this is the log message:

    NullReferenceException: Object reference not set to an instance of an object
    UnityEditor.U2D.Animation.SpriteLibraryEditor.SpriteLibraryEditorWindow.OnDestroy () (at ./Library/PackageCache/com.unity.2d.animation@9.0.3/Editor/SpriteLib/SpriteLibraryEditor/SpriteLibraryEditorWindow.cs:61)
    UnityEditor.EditorApplicationLayout:InitPlaymodeLayout()
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,563
    Another indication this 2022 thing isn't really LTS, despite it being claimed as such. :/

    This specific error, coming from this location (eg, NOT your code, such as
    UnityEditor.Graphs
    ), is often fixed by either Reset Layouts (upper right) or else Right-click Project, Reimport-All.

    Or uninstall the sprite library editor package, then reinstall it.

    Otherwise, if the error is in your code, it's always the same answer:

    The answer is always the same... ALWAYS!

    How to fix a NullReferenceException error

    https://forum.unity.com/threads/how-to-fix-a-nullreferenceexception-error.1230297/

    Three steps to success:
    - Identify what is null <-- any other action taken before this step is WASTED TIME
    - Identify why it is null
    - Fix that

    -------------------------------------

    Extra unwanted packages in new projects (collab, testing, rider and other junk):

    https://forum.unity.com/threads/temp-unityengine-testrunner-dll-error.1133938/#post-7287748

    About the fastest way I have found to make a project and avoid all this noise is to create the project, then as soon as you see the files appear, FORCE-STOP (hard-kill) Unity (with the Activity Manager or Task Manager), then go hand-edit the Packages/manifest.json file as outlined in the above post, then reopen Unity.

    Sometimes the package system gets borked from all this unnecessary churn and requires the package cache to be cleared:

    https://stackoverflow.com/questions/53145919/unity3d-package-cache-errors/69779122