在 Unity 编辑器内的树形视图中显示资产、文件、资产组等之间的依赖关系的插件.
Plugin to display dependencies between assets, files, AddressableAssetGroups, etc. in a tree based view within the Unity editor.
Find the manifest.json file in the packages folder of your project and edit it to look like this:
{
"dependencies": {
"com.innogames.asset-relations-viewer": "https://github.com/innogames/asset-relations-viewer.git",
...
},
}If you are in production and not want to get automatic updates always use a tagged version like:
...
"com.innogames.asset-relations-viewer": "https://github.com/innogames/asset-relations-viewer.git#VERSION_TAG",
...
Menu items sorted from left to right.
**Back button ("Components->ClassMemberVariable).
Align Nodes: If all nodes of the same depth should be aligned horizontally in the displayed tree.
Hide Filtered Nodes: Hide all nodes that are filtered out instead of just graying them out.
Highlight packaged assets: Adds green highlight to nodes which are going to be packed into the app (Are actually used by the game).
Merge Relations: If a node has the same asset as a dependency multiple times, the same dependency is just shown once.
s: If the selected node is an asset, it will be selected in the unity project explorer.
>: Sets node as currently selected node.
The AssetRelationViewer can display several types of dependencies. In order for them to show up these need to be selected first.
After selecting a dependency type that is currently not loaded the Load caches button need to be clicked on in order to finally load the dependency types.
Unused dependency types can be unloaded by clicking on the U button.
L Dependency type is active and currently loaded.
R Dependency type got activated but needs to be loaded.
U Dependency type got deactivated and can be unloaded.
R Button Refreshes the dependencies just for this dependency type.
Dependencies of assets to assets by a UnityEngine.Object reference.
Dependencies of assets to the file they are part of.
This is required since a file can have several sub assets meaning that an asset is not automatically the file itself even though most files only contain a single asset.
Note: Only the file itself has size information about the assets it contains. So in order to get size information with the "Show additional node information" this dependency type need to be enabled.
Dependencies of GameObject to GameObjects within the currently loaded scene or prefab.
If a GameObject is selected as the viewed node only GameObject->GameObject dependencies are shown. The GameObject->GameObject dependency view can not be viewed together with other dependencies.
Note: If the opened scene/prefab changed after opening the AssetRelationViewer the cache needs to be refreshed.
Dependencies between AssemblyDefinitions to other AssemblyDefinitions as well as AssemblyDefinitionReferences to AssemblyDefinitions
The following dependency types are only available if the Unity Addressables addon is added to the project.
In addressables a different Object can be referenced by a so called AssetReference instead of UnityEngine.Object
To display these references this node type needs to be enabled.
AddressableAssetGroups of the Addressable system contain a list of assets.
By enabling this dependency type these assets can be viewed as a dependency.
Used to display the dependency of an asset to the AddressableAssetGroup it is part of.
This is basically the opposite direction of the AddressableAssetGroup->Asset dependency.
This can be used to display bidirectional dependencies between assets and AddressableAssetGroups when also the AddressableAssetGroup->Asset is enabled.
Having both AddressableAssetGroup->Asset and Asset->AddressableAssetGroup enabled at the same time can lead to very large dependency trees if AssetBundles have a lot of dependencies to other AssetBundles.
Most dependency types are cached to only update the dependencies again if the file itself got changed.
This greatly reduces the startup time of the AssetRelationsViewer since for large projects finding all Asset->Asset dependencies can take several minutes. If a file needs to be updated is currently determined by the timestamp of the file but could be changed to in addition also take a file hash into account.
The caches are stored in PROJECT_ROOT/Library/NodeDependencyCache/.
Depending on the project size these files can be several several megabytes in size.
The cache files can either be deleted manually or inside Unity under the Window/Node Dependency Cache/Clear Cache Files menu item.
Since every type of node can be viewed in the AssetRelationViewer like Assets, Files, AddressableAssetGroups, AsmDefs, etc. is sometimes helpful to have a generic node search.
Only known nodes based on the activated dependency types are shown, meaning that only nodes found by any activated DependencyCaches are selectable.
Nodes can be searched for by name and by type.
Based on the filtered name and type the dropdown will show all available nodes to select.
This enables also to find nodes that are otherwise not findable in the explorer, like the Default-Material of Unity.
Once selected in the dropdown the current node can be shown in the AssetRelationsViewer by clicking Select.
To specifically filter for either a node name or node type the "Node hierarchy filter:" can be used.
Only the matching nodes will be highlighted and all others are grayed out.
In the example the dependency tree is filtered for "vertexLit".
In the AssetRelationsViewer it is possible to not only view dependencies between Asset->Asset for example but also exactly through with path the dependency exist.
In order to view the pathes "Show Property Pathes" needs to be activated.
Once active the whole path of the dependency (GameObject->Components->ClassMemberVariable) is shown in the hierarchy tree view.
GUI options specific to a node type.
Options specific to Assets.
Contains dropdown to select an asset in the project.
Sync to explorer: If selected the currently selected asset in the project explorer will be the one shown in the AssetRelationsViewer.
Options specific to Files.
Currently there are no specific options for them.
Options for in scene GameObjects.
Contains dropdown to select a GameObject from the currently opened scene/prefab.
Sync to hierarchy: If selected the currently selected GameObject in the currently opened scene/prefab will be shown in the AssetRelationsViewer.
Doing the whole dependency search in one frame leads to a very high memory consumption since Unity cant really clean memory here. Even calling CG.Collect() several time during the search does not help.
For example, the peak memory consumption of a full update on our live project increases ~10GB when doing a full dependency search. With the async approach this is only increasing ~3GB. This option is enabled by default.
There can be cases where no tree is shown in the AssetRelationsViewer
The dependency cache can be used without the AssetRelationsViewer.
This makes it possible to use the cache for other tools where dependency information between assets, files, etc. is required.
In the following example we find out which asset have a dependency on the BaseProductions prefab.
…Executing this would result in the following output
[GameObject]BaseProductions is directly referenced by [GameObject]ProductionTabContent
For this script to work in your own project the name and type of the asset in AssetDatabase.FindAssets() needs to be adapted accordingly to an asset that exists in your project.
For reduced memory consumption also NodeDependencyLookupUtility.LoadDependencyLookupForCachesAsync(); can be used if executed in an Enumerator. The package provides the EditorCoroutineWithExceptionHandling for starting a coroutine in the editor with exception handling.
var coroutine = new EditorCoroutineWithExceptionHandling();
coroutine.Start(YOUR_COROUTINE_THAT_CALLS_NodeDependencyLookupUtility.LoadDependencyLookupForCachesAsync(),
exception =>
{
EditorUtility.ClearProgressBar();
throw exception;
});Support to display different connection and node types can be added by addons.
Own addons can be also added so custom dependencies with any NodeType and dependency type can be added to be viewed inside the Asset Relations Viewer.
For an example how to create addons please have a look at the Addressables implementation.
暂无开放 Issues,或尚未同步最近议题。