-
Notifications
You must be signed in to change notification settings - Fork 72
Expand file tree
/
Copy pathContentLayout.cs
More file actions
201 lines (167 loc) · 9.07 KB
/
Copy pathContentLayout.cs
File metadata and controls
201 lines (167 loc) · 9.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
// This file defines the structure of the ContentLayout.json file produced by BuildPipeline.BuildContentDirectory
// (available starting in Unity 6.6).
//
// See Documentation/contentlayout.md for further details.
//
// ContentLayout always represents the latest schema version (currently 3, written by Unity 6.7).
// Older versions are preserved under a version-specific namespace: the version 2 schema (Unity 6.6)
// is defined in ContentLayoutV2.cs as UnityDataTools.Models.V2.ContentLayout.
namespace UnityDataTools.Models
{
/// <summary>
/// Category strings used by <see cref="BinaryArtifact.Category"/>.
/// </summary>
public static class BuildArtifactCategory
{
/// <summary>Texture data, written to a streaming resource (.resS) file.</summary>
public const string Texture = "texture";
/// <summary>Mesh data, written to a streaming resource (.resS) file.</summary>
public const string Mesh = "mesh";
/// <summary>Audio data, written to a resource (.resource) file.</summary>
public const string Audio = "audio";
/// <summary>Video data, written to a resource (.resource) file.</summary>
public const string Video = "video";
/// <summary>A SerializedFile / Content File (.cf).</summary>
public const string ContentFile = "contentfile";
/// <summary>A manifest file (.json).</summary>
public const string Manifest = "manifest";
}
/// <summary>
/// Describes a SerializedFile in the build output.
/// </summary>
public struct SerializedFileLayout
{
/// <summary>Index of this entry inside <see cref="ContentLayout.SerializedFiles"/>.</summary>
public int Index;
/// <summary>Stable identity hash of this SerializedFile, used to reference it from other
/// SerializedFiles in a way that doesn't break when the content changes. Computed from the
/// cluster or object identity of the source. For the synthetic built-in entry this is the
/// resource path instead.</summary>
public string StableId;
/// <summary>True for synthetic entries representing built-in Unity resources that are not produced
/// by the build (currently only "Library/unity default resources"); such entries resolve through
/// the PersistentManager at runtime and have no artifact. Only written when true; absent means false.</summary>
public bool IsBuiltIn;
/// <summary>The source assets included in this SerializedFile.</summary>
public string[] SourceAssets;
/// <summary>Indices into the containing <see cref="ContentLayout.SerializedFiles"/> array, identifying
/// other SerializedFiles that need to be loaded prior to loading this SerializedFile.</summary>
public int[] SerializedFileDependencies;
/// <summary>Indices into <see cref="ContentLayout.LoadableObjectIds"/> for loadable objects
/// referenced from this SerializedFile.</summary>
public int[] LoadableDependencies;
/// <summary>Scene paths for scenes referenced from this SerializedFile.</summary>
public string[] LoadableSceneDependencies;
/// <summary>Index into <see cref="ContentLayout.BinaryArtifacts"/> for the artifact holding this
/// SerializedFile's content, or -1 for the built-in entry, which has no artifact.</summary>
public int ArtifactIndex;
}
/// <summary>
/// Records a loadable object in the build. Listed at the top level of the ContentLayout so that a
/// loadable's identity is described independently of the SerializedFile that happens to contain it.
/// Referenced by index from <see cref="SerializedFileLayout.LoadableDependencies"/> and
/// <see cref="ContentLayout.RootAssets"/>.
/// </summary>
public class LoadableObjectIdLayout
{
/// <summary>AssetDatabase GUID of the source asset.</summary>
public string GUID;
/// <summary>Local file id of the object in the output SerializedFile when placed,
/// otherwise the source local file id. Identical to the source id except for MonoScripts.</summary>
public long LFID;
/// <summary>Identifier type of the source object.</summary>
public int IdentifierType;
/// <summary>Index into <see cref="ContentLayout.SerializedFiles"/> for the file that contains this
/// loadable, or -1 if it was dropped (e.g. server build shader references).</summary>
public int SerializedFile = -1;
}
/// <summary>
/// Records a scene exposed as loadable in the build, and the SerializedFile that contains it.
/// </summary>
public class LoadableSceneIdLayout
{
/// <summary>AssetDatabase GUID of the scene.</summary>
public string GUID;
/// <summary>Scene path.</summary>
public string Path;
/// <summary>Index into <see cref="ContentLayout.SerializedFiles"/>, or -1 if not mapped.</summary>
public int SerializedFile = -1;
}
/// <summary>
/// Describes a binary artifact produced by the build (SerializedFile, streaming resource, manifest, etc.).
/// </summary>
public class BinaryArtifact
{
/// <summary>Index of this entry inside <see cref="ContentLayout.BinaryArtifacts"/>.</summary>
public int Index;
/// <summary>Content addressable hash. For ContentFile artifacts, the matching
/// <see cref="SerializedFileLayout"/> references this entry via
/// <see cref="SerializedFileLayout.ArtifactIndex"/>.</summary>
public string ContentHash;
/// <summary>One of the strings in <see cref="BuildArtifactCategory"/>.</summary>
public string Category;
/// <summary>Size in bytes.</summary>
public ulong Size;
/// <summary>Indices into <see cref="ContentLayout.BinaryArtifacts"/> identifying additional artifacts
/// referenced from this one (e.g. mesh, audio).
/// Note: this does not track references to other ContentFiles — those are recorded in
/// <see cref="SerializedFileLayout.SerializedFileDependencies"/>.</summary>
public int[] ArtifactReferences;
/// <summary>The on-disk file extension for this artifact, derived from <see cref="Category"/>.
/// For unrecognized categories, returns the category name.</summary>
public string FileExtension
{
get
{
switch (Category)
{
case BuildArtifactCategory.Texture:
case BuildArtifactCategory.Mesh:
return ".resS";
case BuildArtifactCategory.Audio:
case BuildArtifactCategory.Video:
return ".resource";
case BuildArtifactCategory.ContentFile:
return ".cf";
case BuildArtifactCategory.Manifest:
return ".json";
default:
return string.IsNullOrEmpty(Category) ? "" : "." + Category;
}
}
}
}
/// <summary>
/// In-memory representation of the ContentLayout.json file written by the build.
///
/// The Layout is a companion to the BuildManifest, recording additional details about the build
/// (including source assets and information about which source object each loadable refers to).
/// It is not shipped with the build; it exists for tools and tests that analyze build output.
/// The schema is subject to change and there is currently no backward compatibility.
/// </summary>
public class ContentLayout
{
/// <summary>The schema version this type represents.</summary>
// v1 -> v2: added OutputLFID to LoadableObjectIds entries.
// v2 -> v3: ObjectIdHash deleted. LoadableObjectIds entries trimmed to {GUID, LFID,
// IdentifierType, SerializedFile}; LoadableDependencies and RootAssets became
// indices into LoadableObjectIds. SerializedFiles entries carry StableId
// (the identity hash, no extension) instead of ID, and ArtifactIndex (index
// into BinaryArtifacts) instead of ContentHash.
public const int CurrentVersion = 3;
/// <summary>Schema version of the ContentLayout.json file.</summary>
public int Version;
/// <summary>Hash of the BuildManifest this layout corresponds to.</summary>
public string BuildManifestHash;
/// <summary>The SerializedFiles in the build output.</summary>
public SerializedFileLayout[] SerializedFiles;
/// <summary>Indices into <see cref="LoadableObjectIds"/> of the root assets, in root input order.</summary>
public int[] RootAssets;
/// <summary>Loadable objects in the build.</summary>
public LoadableObjectIdLayout[] LoadableObjectIds;
/// <summary>Loadable scenes in the build.</summary>
public LoadableSceneIdLayout[] LoadableSceneIds;
/// <summary>Binary artifacts produced by the build.</summary>
public BinaryArtifact[] BinaryArtifacts;
}
}