What to do when Unity thinks a script is broken

I made changes to Pathfinder.cs, and unfortunately I tried to make a method called ‘pathfinder()’ by mistake. Visual Studio freaked out, and wouldn’t let me make any more methods. I switched over to Unity, and it said the pathfinder.cs script had an error and couldn’t continue until the error was cleared. I tried removing the component, I tried reimporting the (fixed) pathfinder.cs script. Nothing worked. I reverted to a save point in Sourcetree, and that fixed it. But I’d like to know how to get Unity to let go of a problem script and let me fix it.

(I recall a video where a component was broken and someone said not to remove it, there was another answer… ring any bells?)

Visual Studio seems to loose “connection” to Unity sometimes, and will have problems finding classes and C# commands from Unity.

Normally restarting just Visual Studio fixes this issue for me…

About the ringing bell, you can use Visual Studio’s Find function (CTRL or COMMAND F) to find all the references of a function in all the scripts.

Thanks @Mellow, I’m getting much better since that post at making frequent save points with Sourcetree. It’s still frustrating to lose work, but that’s part of the learning curve!
Thanks for the answer :slight_smile:

Privacy & Terms