- Home /
Does AssetDatabase.GetDependencies return unpacked prefabs as well?
I am trying to get a list of all prefabs in use in my project.
I am grabbing the scenes using the following code:
foreach (UnityEditor.EditorBuildSettingsScene S in UnityEditor.EditorBuildSettings.scenes)
and then I use:
AssetDatabase.GetDependencies(scene, true);
to look for dependencies, and finally I check the extension to see if the dependency is a prefab.
However, it seems to be returning prefabs that I don't think I have any instances of in my project. The only use I find of the prefab is where the prefab is unpacked. Unpacked prefabs shouldn't be considered a dependency of the scene though, I would think.
Currently my list of prefabs is about 500 but I was hoping that all unpacked prefabs would not show up as dependencies. That way I could upload only the prefabs in use to the git repository.
Answer by knightpraetor · Jul 06, 2020 at 06:27 AM
I found the answer. In versions prior 2018.3, there was no button for unpack prefab completely. So even though the prefab is unpacked, it still contains a dependency in some cases (prefab variant, etc).
You can destroy the dependency by making a new basic prefab and then breaking the prefab and deleting the prefab.
My team lead is averse to upping the unity version of the project because he says it will break things. However, manually going and removing all these dependencies so that we can grab only the used dependencies to upload to git seems like it will be too much of a hassle.
Your answer
Follow this Question
Related Questions
Prefabs in git 1 Answer
Can't drag and drop prefabs made by other people on my team (Git/Git LFS) 0 Answers
Models in prefab are broken after updating .fbx file 0 Answers
Adding slots (prefabs) in a grid to an inventory (canvas) by relative positioning 1 Answer
Increasing through a list after an object has been destroyed 2 Answers