- Home /
Losing references after changing folders
Hello,
After moving scripts around in the Unity editor, and manually renaming an unrelated one, my scripts seem to have lost all references to some moved classes. They don't show up in regular "using"s. I realize this is probably a common problem. Here's an example of a messed-up script.
I appreciate any answers or guides in the right direction.
Update: I've tried just simply restarting Visual Studio, rebuilding the project. All META files seem to be in the right places.
Update: The problem is fixed when I move all the trouble scripts into the folders they have trouble referencing. The problem seemed to be scripts losing the references to their old folder, when they were moved away (horizontally or vertically) from the folder they were created in. This works, but I'd still like to move things around, so if someone has insights, let me know.
Update: The problem has been getting larger, and I've been needing to move more scripts into the same folder as they slowly lose references. "Referenced script cannot be found" errors in the editor sometimes appear, fixed by reloading Unity.
Answer by kuijerlattie · Mar 22, 2018 at 11:17 AM
possible solution 1:
close your visual studio. go to the file that is messed up (in this case ShipEditorMovement.cs) within unity. right click and reimport. open by double clicking.
that should fix it. if not:
close visual studio again. move the file to a different folder within your unity project. move it back to where it belongs. open it by double clicking.
Ok, tried reimporting one, but ins$$anonymous$$d of fixing errors in Visual Studio, it just made a whole bunch in Unity that, once I checked on them, weren't actually there.
If you see my edit above, moving the scripts back to their original folder worked, but moving them away again created the same errors.
if you close visual studio and then move the files in unity it should work fine.
Nah that didn't work, I was very thorough about the closing and reloading of programs. Thanks for the attempt though, and it partially worked too.
This definitely worked for me after about a half hour of updating and clicking around madly. Thanks!!!