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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Resolved Scripts Not Found following Unity project folder rename/move

Discussion in 'Scripting' started by ben4d85, Mar 30, 2023.

  1. ben4d85


    Dec 26, 2018
    I have renamed and moved the folder that contains my Unity project.

    The Unity Editor now no longer finds my existing scripts on game objects, nor lets me add new scripts to game objects.

    There are no bugs or warnings in the console. But when I enter Play Mode, I get the following warning in the console for every single script on every single game object: "The referenced script on this Behaviour (Game Object 'XYZ') is missing!"

    Issue 1: Script can't be loaded
    Existing script on a game object. It was fine when I last left the Editor, but now it can't be loaded. It has not been renamed. The file name and class name do match. This screenshot is just one example, but this issue applies to all my scripts on all my game objects throughout my entire project.

    Screenshot 1.png

    When I open Prefab Mode as the message suggests, it looks like this:

    Screenshot 1-5.png

    You can tell that there is a problem because it displays "(Script)" instead of the name of the script. It also is not displaying any of the serialized fields.

    Issue 2: Can't add script
    Trying to add a script to a game object.

    Screenshot 2.png

    Attempted fixes:
    • I went to Unity > Preferences > External Tools and clicked "Regenerate project files". I closed and reopened Unity. This did not fix it.
    • I noticed that I now have two sln files, one with the old name and one with the new. I deleted the sln file with the old name. I closed and reopened Unity. This did not fix it.
    • I noticed that the files Assembly-CSharp-Editor.csproj and Assembly-CSharp-firstpass.csproj both contain many occurrences of the old project path. So I replaced those with the new project path. I closed and reopened Unity. This did not fix it.
    • In the Project window, I right-clicked on my Scripts folder and selected "Reimport". It reimported and reloaded the domain. No errors in the console. I closed and reopened Unity. This did not fix it.
    • In the Project window, I right-clicked on my Prefabs folder and selected "Reimport". I closed and reopened Unity. This did not fix it.
    My project is basically broken now. How can this be solved, please?
    Last edited: Mar 30, 2023
  2. Kurt-Dekker


    Mar 16, 2013
    Scroll down for the section on renaming and missing scripts:

    Lost progress / project / work / stuff disappeared in Unity.

    This article is to help you when you have lost significant progress or work in your Unity project.

    It is designed to give you avenues of discovery and investigation.

    It is NOT a guarantee of restoring your lost work. It is NOT a substitute for proper IT / Data security procedures.

    To decide which parts are applicable to you, look for major bolded headings.


    Your project probably is still on your computer. Try a computer-wide search for some unique filenames that you know are in the project you think is gone.

    To start your search, one common file to all Unity projects is named

    Some things that might have happened:

    - you are not opening the project that you think you are
    - you are in the correct project but not opening the same scene you had open before
    - you dragged the project (or part of it) into the trash (intentionally or inadvertently)
    - you moved the project (or part of it) somewhere else (intentionally or inadvertently)
    - an overly-aggressive antivirus solution quarantined it because it saw code being compiled in there
    - you're using a directory sync like OneDrive or Dropbox... NEVER USE THESE SERVICES WITH UNITY!
    - something else??

    As I said, it's probably still all on your system to be found if you look in the right places.

    A typical Unity project will have at a minimum the following folders:



    Close Unity and make a full project backup RIGHT NOW. Do not do ANYTHING else until you back it up 100%.

    Ideally copy that backup to another computer, or back it up to another external hard drive entirely. This is just basic data processing best practices during data recovery operations.

    If you can see all the files and folders of your project, make sure you are opening the scene file you were working in.

    Once you have opened the scene, look in the hierarchy window, select an object and move the mouse over the Scene window and press F to focus that object.

    Additional notes:

    - ALWAYS use proper industrial grade source control (see below)
    - NEVER use Dropbox or any file sync mechanism in Unity.
    - NEVER move files within your project, except by doing it within Unity
    - ALWAYS be sure you are fully backed up before upgrading Unity


    Some info about Missing script warnings, broken prefabs, GUIDs, renaming GUIDs, etc:

    EVERYTHING in Unity is connected to the above GUID, which is stored ONLY in the metafile, and hence why the metafiles ALWAYS MUST be source-controlled.

    When Renaming: It is super-easy to inadvertently change the GUID by renaming outside of Unity. Don't do that. Instead:

    - close Visual Studio (important!)
    - rename the file(s) in Unity
    - in Unity do Assets -> Open C# Project to reopen Visual Studio
    - now rename the actual classes, and MAKE SURE THE FILE NAMES DO NOT CHANGE!

    If you are NOT using source control while you do this, renaming files is an EXTREMELY dangerous process. Use source control at all times so that you can trivially revert if you miss a critical step and damage your project.


    You must isolate if there is something wrong with your Unity installation, something wrong with your project, or perhaps just a corrupted import or asset database.

    First, ALWAYS back your project up. Then try deleting the
    folders that are within your project, the directories that are peers to the

    If that doesn't work it is time to bisect. Make a new empty project and get Unity to open that. If you cannot then it is time to fix your Unity installation, either by fully reinstalling or verifying it with the hub.

    Once you have an empty project open, begin copying over your project. Try the entire thing. If it crashes, try half of the project, then the other half, etc.

    As always, if you're using Windows, another "first thing to try" is to simply reboot the system. This often fixes typical Windows issues related to locked files and locked directories.

    ISSUES RELATED TO UPGRADING PROJECTS (eg, changing to a higher Unity version)

    Upgrading to a later version of Unity is a one-way process. Any project that has been updated should NEVER be reverted to an earlier version of Unity because this is expressly not supported by Unity. Doing so exposes your project to internal inconsistencies and breakage that may actually be impossible to repair.

    If you want to upgrade to a newer version of Unity, do not even consider it until you have placed your project fully under proper source control. This goes double or triple for non-LTS (Tech Stream) versions of Unity3D, which can be extremely unstable compared with LTS.

    Once you have source-controlled your project then you may attempt a Unity upgrade. Immediately after any attempted upgrade you should try to view as much of your project as possible, with a mind to looking for broken animations or materials or any other scripting errors or runtime issues.

    After an upgrade you should ALWAYS build to all targets you contemplate supporting: iOS and Android can be particularly finicky, and of course any third party libraries you use must also "play nice" with the new version of Unity. Since you didn't write the third party library, it is up to you to vet it against the new version to make sure it still works.

    If there are issues in your testing after upgrading Unity, ABANDON the upgrade, revert your project in source control and be back where you were pre-upgrade with the earlier version of Unity.

    Obviously the less you test after the upgrade the more chance you will have of an undiscovered critical issue.

    This risk of upgrading is entirely on you and must be considered whenever you contemplate a Unity version upgrade.

    Do not upgrade "just for fun" or you may become very unhappy.


    I'm sorry you've had this issue. Please consider using proper industrial-grade enterprise-qualified source control in order to guard and protect your hard-earned work.

    Personally I use git (completely outside of Unity) because it is free and there are tons of tutorials out there to help you set it up as well as free places to host your repo (BitBucket, Github, Gitlab, etc.).

    You can also push git repositories to other drives: thumb drives, USB drives, network drives, etc., effectively putting a complete copy of the repository there.

    As far as configuring Unity to play nice with git, keep this in mind:

    I usually make a separate repository for each game, but I have some repositories with a bunch of smaller test games.

    Here is how I use git in one of my games, Jetpack Kurt:

    Using fine-grained source control as you work to refine your engineering:

    Share/Sharing source code between projects:

    Setting up an appropriate .gitignore file for Unity3D:

    Generally setting Unity up (includes above .gitignore concepts):

    It is only simple economics that you must expend as much effort into backing it up as you feel the work is worth in the first place. Digital storage is so unbelievably cheap today that you can buy gigabytes of flash drive storage for about the price of a cup of coffee. It's simply ridiculous not to back up.

    If you plan on joining the software industry, you will be required and expected to know how to use source control.

    "Use source control or you will be really sad sooner or later." - StarManta on the Unity3D forum boards
    Bunny83 and ben4d85 like this.
  3. ben4d85


    Dec 26, 2018
    Update: Resolved.

    When I reimported the Prefabs folder, the console displayed a warning mentioning "inconsistent behaviour" in one particular script (sadly, I am not able to reproduce it now and I don't recollect the exact wording of the message). This is a script that (at least to my recollection) is not attached to any game object, and it definitely contains no errors.

    I opened this script and commented out the whole content of the class. Following a recompile, all my scripts can be loaded again now and the issues mentioned in this ticket have disappeared.

    I have since commented the content of that class back in. And the problem did not reappear. So I doubt that the script is to blame. I still don't understand why this happened.