BuildManifestHash
Identifies the build that produced the content directory.
Read time 2 minutesLast updated 2 days ago
Definition
- Type: Property
- Namespace: Unity.Loading
- Assembly: UnityEngine.ContentLoadModule
public Hash128 BuildManifestHash { get; }
Remarks
It is the hash in the content directory's file, and the value of the build's file. In the Editor, pass it to BuildHistory.TryGetBuildSummaryForManifestHash to find the build in this project's build history. ContentDirectoryDiagnostics describes how to keep the layout of builds that the build history does not have.
BuildManifestHash.txtBuildManifestHashContentLayout.jsonThe hash is a default Hash128 when the content directory is not registered.
Examples
using System;using System.Collections.Generic;using System.IO;using UnityEditor.Build;using UnityEngine;namespace BuildDocExamples{ // Example: name the files of a ContentDirectoryLoadInfo that a Player sent back. The Player sends // ContentDirectoryLoadInfo.BuildManifestHash and, for each file, ContentFileIdentity.ToString(). In // the Editor, the hash finds the build in this project's build history, and each identity is the // StableId of one entry of that build's ContentLayout.json file. public static class ContentDirectoryLoadInfo_BuildManifestHashExample { // The parts of ContentLayout.json that this example reads. [Serializable] class ContentLayout { public SerializedFile[] SerializedFiles; } [Serializable] class SerializedFile { public string StableId; public string[] SourceAssets; } public static void LogSourceAssets(Hash128 buildManifestHash, IEnumerable<string> fileIdentities) { if (!BuildHistory.TryGetBuildSummaryForManifestHash(buildManifestHash, out var summary) || !BuildHistory.TryGetFilePath(summary.BuildSessionGUID, "ContentLayout.json", out string layoutPath)) { Debug.LogWarning($"Build {buildManifestHash} is not in this project's build history."); return; } var layout = JsonUtility.FromJson<ContentLayout>(File.ReadAllText(layoutPath)); var sourceAssets = new Dictionary<string, string[]>(); foreach (SerializedFile file in layout.SerializedFiles) sourceAssets[file.StableId] = file.SourceAssets; foreach (string identity in fileIdentities) { // The paths are the ones the assets had when the content was built. string description = sourceAssets.TryGetValue(identity, out string[] assets) && assets.Length > 0 ? string.Join(", ", assets) : "no source asset"; Debug.Log($"{identity}: {description}"); } } }}