Search Unity

Cleaning old hidden references from script on prefab

Discussion in 'Scripting' started by maxxa05, Oct 7, 2016.

  1. maxxa05

    maxxa05

    Joined:
    Nov 17, 2012
    Posts:
    186
    So, when using AssetDatabase.GetDependencies on a prefab, I get old references to other assets whose referencing fields were removed months ago from a script on the prefab. If I clean my prefab by manually deleting references in the inspector. I still see those assets when I check dependencies. Even if I use the Debug inspector, I still don't see those references. I guess Unity keeps those in the background in case I want to put back the fields they were assigned to. It selects those references if I use Select Dependencies in the project view. I wouldn't be surprised if they are even built in my game and loaded in memory when I load the prefab, even if I don't use them anymore.

    The only fix I know for now is to manually break the reference by deleting the other assets (after duplicating them if I use those assets elsewhere). Is there a way to clean those references by script? Or maybe even an button in the editor I never noticed?
     
  2. Diet-Chugg

    Diet-Chugg

    Joined:
    Jul 4, 2012
    Posts:
    51
    I am having the same problem.
     
  3. maxxa05

    maxxa05

    Joined:
    Nov 17, 2012
    Posts:
    186
    This should definitely appear in the debug inspector, at least we could easily clean them this way. I might try to make a tool that will clean those references when I'll have a bit of time, I'll post it here.