---
title: ContentLoadState
product: Unity Editor
version: '7000.0'
latest_version: '7000.0'
status: This page documents version 7000.0. The latest version is 7000.0.
canonical: https://docs.unity.com/en-us/engine/7000.0/script-reference/unity/loading/contentloadstate
latest_url: https://docs.unity.com/en-us/engine/7000.0/script-reference/unity/loading/contentloadstate.md
last_updated: 2026-11-07
generated_at: 2026-11-10T14:37:22.710Z
locale: en-us
---

# ContentLoadState

> A snapshot of what is loaded from one content directory: the content files in memory, the loaded scenes, and the dependencies between them.

## Definition

* **Type:** Class
* **Namespace:** [Unity.Loading](/engine/7000.0/script-reference/unity/loading.md)
* **Assembly:** UnityEngine.ContentLoadModule

```csharp
public sealed class ContentLoadState
```

## Remarks

[ContentDirectoryDiagnostics.GetContentDirectoryLoadInfo](/engine/7000.0/script-reference/unity/loading/contentdirectorydiagnostics/getcontentdirectoryloadinfo.md) fills the state in [ContentDirectoryLoadInfo.LoadState](/engine/7000.0/script-reference/unity/loading/contentdirectoryloadinfo/loadstate.md). The lists stay empty in release Players.

The lists refer to each other by index. Each file and scene names a range of [ContentLoadState.Dependencies](/engine/7000.0/script-reference/unity/loading/contentloadstate/dependencies.md), and each entry of that range is the index in [ContentLoadState.Files](/engine/7000.0/script-reference/unity/loading/contentloadstate/files.md) of a file it depends on. An index is only valid in the state it comes from. To follow a file from one state to another, compare [LoadedContentFileInfo.Identity](/engine/7000.0/script-reference/unity/loading/loadedcontentfileinfo/identity.md).

The lists do not change after the call, so a state can be kept after the content directory is unregistered or after Play mode ends. [LoadedSceneInfo.Scene](/engine/7000.0/script-reference/unity/loading/loadedsceneinfo/scene.md) refers to a live scene, which can be unloaded after the call.

To find the source assets of a file, look up [ContentFileIdentity.ToString](/engine/7000.0/script-reference/unity/loading/contentfileidentity/tostring.md) in the build's `ContentLayout.json` file, as [ContentDirectoryDiagnostics](/engine/7000.0/script-reference/unity/loading/contentdirectorydiagnostics.md) describes. This also works for a state filled in a Player: send each [ContentFileIdentity.ToString](/engine/7000.0/script-reference/unity/loading/contentfileidentity/tostring.md) with the [ContentDirectoryLoadInfo.BuildManifestHash](/engine/7000.0/script-reference/unity/loading/contentdirectoryloadinfo/buildmanifesthash.md). In the Editor, [ContentLoadEditorUtility.TryGetSourceAssetGUID](/engine/7000.0/script-reference/unityeditor/contentloadeditorutility/trygetsourceassetguid.md) gives the source asset directly.

Additional Resources: [ContentDirectoryDiagnostics.GetContentDirectoryLoadInfo](/engine/7000.0/script-reference/unity/loading/contentdirectorydiagnostics/getcontentdirectoryloadinfo.md)

## Examples

```csharp
using System.Collections.Generic;
using Unity.Loading;
using UnityEditor;
using UnityEngine;

namespace BuildDocExamples
{
    // Example: find what a level loaded and did not release. Count the holds that game code keeps on
    // each content file before the level loads, and again after it unloads. A file that game code
    // holds more often afterwards is held by a Loadable that the level loaded and did not release.
    // The same asset built into two content directories has the same identity in both, so the counts
    // are kept per directory.
    public class ContentDirectoryDiagnostics_GetContentDirectoryLoadInfoExample
    {
        readonly ContentDirectoryLoadInfo m_Info = new ContentDirectoryLoadInfo();
        readonly Dictionary<(ContentDirectoryHandle, ContentFileIdentity), int> m_HoldsBeforeLevel =
            new Dictionary<(ContentDirectoryHandle, ContentFileIdentity), int>();

        public void OnBeforeLevelLoads()
        {
            m_HoldsBeforeLevel.Clear();
            foreach (ContentDirectoryHandle directory in ContentLoadManager.GetContentDirectories())
            {
                ContentDirectoryDiagnostics.GetContentDirectoryLoadInfo(directory, m_Info);
                for (int i = 0; i < m_Info.LoadState.Files.Count; i++)
                    m_HoldsBeforeLevel[(directory, m_Info.LoadState.Files[i].Identity)] = GameCodeHolds(i);
            }
        }

        public void OnAfterLevelUnloads()
        {
            foreach (ContentDirectoryHandle directory in ContentLoadManager.GetContentDirectories())
            {
                ContentDirectoryDiagnostics.GetContentDirectoryLoadInfo(directory, m_Info);
                ContentLoadState state = m_Info.LoadState;
                for (int i = 0; i < state.Files.Count; i++)
                {
                    LoadedContentFileInfo file = state.Files[i];
                    m_HoldsBeforeLevel.TryGetValue((directory, file.Identity), out int holdsBefore);
                    int notReleased = GameCodeHolds(i) - holdsBefore;
                    if (notReleased > 0)
                        Debug.LogWarning($"{notReleased} Loadable(s) not released after the level unloaded, in {NameOf(file.Identity)}");
                }
            }
        }

        // Unity holds the files of root assets for the content directory. The other holds come from game code.
        int GameCodeHolds(int fileIndex)
        {
            return m_Info.LoadState.Files[fileIndex].ReferenceCount - m_Info.RootAssetReferences[fileIndex];
        }

        // In the Editor, name the asset that the file was built from. Elsewhere, the identity is the
        // file's StableId in the ContentLayout.json file of the build that ContentDirectoryLoadInfo.BuildManifestHash names.
        static string NameOf(ContentFileIdentity file)
        {
            return ContentLoadEditorUtility.TryGetSourceAssetGUID(file, out GUID guid)
                ? AssetDatabase.GUIDToAssetPath(guid)
                : file.ToString();
        }
    }
}
```

## Properties

| Property                                                                                       | Description                                                                                                                                                |
| ---------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [Dependencies](/engine/7000.0/script-reference/unity/loading/contentloadstate/dependencies.md) | Indices into [ContentLoadState.Files](/engine/7000.0/script-reference/unity/loading/contentloadstate/files.md), in one range for each file and each scene. |
| [Files](/engine/7000.0/script-reference/unity/loading/contentloadstate/files.md)               | The content files of the content directory that are in memory, including those loaded only as dependencies.                                                |
| [Scenes](/engine/7000.0/script-reference/unity/loading/contentloadstate/scenes.md)             | The scenes loaded from the content directory.                                                                                                              |
