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
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

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.