How to restore public variable's references after fix script error?

I got tons of inspector public variables setting, but after some error on script, I fixed script, then all of inspector’s reference objects become null. I got hundreds of them.

Why this happen how to restore?

I am very upset.

Do you have version control? If so save everything and then revert all objects and meta files except for the fixed script.

Note that changing the name of a variable will in essence delete the first variable and create a new unassigned variable, so if your fix involved changing names of variables then you’ll have to change them back, or you could keep the old variables there, and then write an editor script to assign the value of the old variables to the new ones.

If you don’t have version control… Get version control so that this doesn’t happen to you again.

There is [FormerlySerializedAs] but I’m not sure if it will repair this situation. The real fix is understanding how serialization handles things so you don’t break things and using version control so you can revert when you do break things.

Oh wow, I have to look this up!

Recommend some version control please.

It’s hard as I don’t know your requirements. They all come with their pros and cons.