NullReferenceException

Hello,
I am following a 2D game tutorial ( 2D Roguelike - Unity Learn ) I did everything as it was in the tutorial, when I ran my project, unity kept loading for like 10 minutes after losing hope for it to load, I ended unity task in task manager, before running the project I was able to drag my prefabs in the script slots (I don’t know how it’s called, sorry) everything was fine except that it didn’t load. After I shut down unity via task manager and opened up my project again, the scene wasn’t saved, however, I had all of my prefabs and scripts saved but now when I have a script added to a gameObject and when I try to add prefabs to that script (which again, I was able to do fine before I shut it down) it gives me this error:

I don’t understand how restarting a program can change my prefabs so that I can’t use them anymore? Also, what can I do to fix it, do I have to create all of the prefabs again?

Thanks

if you add gameobject references to prefabs AND you already have instances of that prefab in the scene, the scene instances wont automagically get the same reference assigned, you either need to re-instantiate it or use the prefab related buttons at the top of the instance in the inspector.

1 Like

I am fairly new to game development, so I didn’t quite understand what you meant, however I fixed this issue by deleting all of the prefabs and making them again. Thanks for your reply though.