- Home /
Getting direct dependencies for an asset
I'd like how can i retrieve an asset's direct dependencies (non-transitive).
The AssetDatabase.GetDependencies method will return transitive dependencies.
By transitive, i mean:
Prefab A references Prefab B (e.g: has a script with a GameObject field that gets set to Prefab B).
Prefab B references an AudioClip
When requesting the dependencies of Prefab A, the AudioClip is also returned (even though it is not a direct dependency).
I want an API (or some other way) to find out the direct dependencies of an asset.
Answer by RedVonix · Aug 27, 2014 at 06:14 AM
Unity doesn't allow prefabs to use other prefabs. Your best bet is to do treat prefab B as a resource and load it through prefab A when you need it. Or if not as a resource, have a script in prefab a reference and Instantiate prefab b.
What I meant was for example Prefab A has a script with a public GameObject field. I hook Prefab B to that in the inspector. So, prefab A does reference prefab B. You are right that prefabs are not nested, but that is irrelevant to this question. I am interested in finding the dependencies, not loading it.