| Parameter | Description |
|---|---|
| pathName | The project-relative path of the asset to get the dependencies of. |
string[] The project-relative paths of the dependencies, including the input path.
Gets the paths of all the assets that the asset at a path depends on, directly or indirectly.
This method returns every asset that the input references, but not all of them are necessarily needed in a build. It returns only assets, not objects inside a file. For example, if a scene contains GameObjects that use a material, the method returns the path of the material but not the GameObjects. This overload includes indirect dependencies and the input path itself. To get only direct dependencies, use the overload that takes recursive.
| Parameter | Description |
|---|---|
| pathName | The project-relative path of the asset to get the dependencies of. |
| recursive | Set to true to include indirect dependencies and the input paths themselves. Set to false to include only direct dependencies. |
string[] The project-relative paths of the dependencies.
Gets the paths of the assets that the asset at a path depends on, with the option to include indirect dependencies.
This method returns every asset that the input references, but not all of them are necessarily needed in a build. It returns only assets, not objects inside a file. For example, if a scene contains GameObjects that use a material, the method returns the path of the material but not the GameObjects.
| Parameter | Description |
|---|---|
| pathNames | The project-relative paths of the assets to get the dependencies of. |
string[] The project-relative paths of the dependencies, including the input paths.
Gets the paths of all the assets that a list of assets depends on, directly or indirectly.
This method returns every asset that the input references, but not all of them are necessarily needed in a build. It returns only assets, not objects inside a file. For example, if a scene contains GameObjects that use a material, the method returns the path of the material but not the GameObjects. This overload includes indirect dependencies and the input paths themselves. To get only direct dependencies, use the overload that takes recursive.
using System.Text; using UnityEditor; using UnityEngine;
public class GetDependenciesExample : MonoBehaviour { [MenuItem("APIExamples/GetDependencies")] static void GetAllDependenciesForScenes() { var allScenes = AssetDatabase.FindAssets("t:Scene"); string[] allPaths = new string[allScenes.Length]; int curSceneIndex = 0;
foreach (var guid in allScenes) { var path = AssetDatabase.GUIDToAssetPath(guid); allPaths[curSceneIndex] = path; ++curSceneIndex; }
var dependencies = AssetDatabase.GetDependencies(allPaths);
StringBuilder dependenciesString = new StringBuilder(); dependenciesString.AppendLine();
foreach (var curDependency in dependencies) { dependenciesString.Append(curDependency); dependenciesString.AppendLine(); }
Debug.Log("All dependencies for Scenes in Project: " + dependenciesString); } }
| Parameter | Description |
|---|---|
| pathNames | The project-relative paths of the assets to get the dependencies of. |
| recursive | Set to true to include indirect dependencies and the input paths themselves. Set to false to include only direct dependencies. |
string[] The project-relative paths of the dependencies.
Gets the paths of the assets that a list of assets depends on, with the option to include indirect dependencies.
This method returns every asset that the input references, but not all of them are necessarily needed in a build. It returns only assets, not objects inside a file. For example, if a scene contains GameObjects that use a material, the method returns the path of the material but not the GameObjects.