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

NullReferenceException

Discussion in 'Editor & General Support' started by MatrixGfx, Jan 2, 2016.

  1. MatrixGfx

    MatrixGfx

    Joined:
    Jul 3, 2015
    Posts:
    31
    Hello,
    I am following a 2D game tutorial ( http://unity3d.com/learn/tutorials/projects/2d-roguelike-tutorial ) 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:

    unity problem.png

    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
     
  2. Flavelius

    Flavelius

    Joined:
    Jul 8, 2012
    Posts:
    925
    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.
     
    MatrixGfx likes this.
  3. MatrixGfx

    MatrixGfx

    Joined:
    Jul 3, 2015
    Posts:
    31
    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.