- Home /
Checking dependency of a prefab
Hi guys, been searching around and didn't seem to find any related questions to this.
Is there a way to check the list of instances used of a prefab? Let's say for example I have a prefab that is used across several scenes. For some reason I wanted to delete this prefab and I wanted to check the name and number of instances this prefab is linked with so that I can clean up my scenes. Is there an option somewhere that can do that?
Cheers, Terry
Answer by Torque14 · Apr 19, 2012 at 10:28 PM
I've been trying to find this answer myself. I need to know when a dependency is updated so I can build the bundle that contains the prefab.
Somebody suggested to me to build a bundle with the prefab in it and crawl the log to get that bundles dependencies but I haven't verified that even works properly yet.
I think your problem is kind of different, but I needed the exact same and found http://unity3d.com/support/documentation/ScriptReference/EditorUtility.CollectDependencies.html, works as expected. e.g.:
var prefab = AssetDatabase.Load$$anonymous$$ainAssetAtPath( prefabAssetPath ); foreach ( var dependency in EditorUtility.CollectDependencies( new[]{ prefab } ) ) { var dependencyPath = AssetDatabase.GetAssetPath( dependency ); if ( string.IsNullOrEmpty( dependencyPath ) ) continue; // ... }
hope it will help :)