4
\$\begingroup\$

Most of my Unity project code is in a visual studio project, and I use Unity for UI/Rendering/wiring things together.

I renamed some fields in an object and suddenly the game, when run in unity, became unrunnably buggy. It turned out that a field I had set in the unity frontend had been unset when I renamed it.

What's a good way to avoid these sorts of problems when working with unity? I was using version control and could have reverted to an old build in the worst case, but I couldn't find any human-readable Unity Scene files that could have just shown me what I changed.

\$\endgroup\$
1

1 Answer 1

9
\$\begingroup\$

For refactoring fields check out the FormerlySerializedAs attribute. See: https://docs.unity3d.com/ScriptReference/Serialization.FormerlySerializedAsAttribute.html

When changing class names make sure that the file and the respective meta file is also renamed accordingly.

\$\endgroup\$
1
  • \$\begingroup\$ Oh fantastic, I didn't know this was a thing. Awesome. I've just always been careful to not rename my fields, or if I do, know that they're going to get untethered, and fix 'em. \$\endgroup\$ Apr 26, 2017 at 12:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .