initial commit
This commit is contained in:
parent
6715289efe
commit
788c3389af
37645 changed files with 2526849 additions and 80 deletions
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: a4c1f91c2b38c564e9e4ab0c5ff1ac1a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,274 @@
|
|||
namespace UnityEditor.AddressableAssets.Build.Layout
|
||||
{
|
||||
/// <summary>
|
||||
/// UnityEngine Object types found as Assets
|
||||
/// </summary>
|
||||
public enum AssetType
|
||||
{
|
||||
/// <summary>
|
||||
/// Unknown type that is not handled
|
||||
/// </summary>
|
||||
Other = 0,
|
||||
|
||||
// Other
|
||||
/// <summary>
|
||||
/// Font asset
|
||||
/// </summary>
|
||||
Font,
|
||||
|
||||
/// <summary>
|
||||
/// GUISkin asset
|
||||
/// </summary>
|
||||
GUISkin,
|
||||
|
||||
// Animation
|
||||
/// <summary>
|
||||
/// AnimationClip, often a subObject of a Model asset
|
||||
/// </summary>
|
||||
AnimationClip,
|
||||
|
||||
/// <summary>
|
||||
/// Avatar asset
|
||||
/// </summary>
|
||||
Avatar,
|
||||
|
||||
/// <summary>
|
||||
/// AnimationController asset
|
||||
/// </summary>
|
||||
AnimationController,
|
||||
|
||||
// Audio
|
||||
/// <summary>
|
||||
/// AudioClip asset
|
||||
/// </summary>
|
||||
AudioClip,
|
||||
|
||||
/// <summary>
|
||||
/// AudioMixer asset
|
||||
/// </summary>
|
||||
AudioMixer,
|
||||
|
||||
// Video
|
||||
/// <summary>
|
||||
/// Video asset
|
||||
/// </summary>
|
||||
VideoClip,
|
||||
|
||||
// Shader
|
||||
/// <summary>
|
||||
/// Shader asset
|
||||
/// </summary>
|
||||
Shader,
|
||||
|
||||
/// <summary>
|
||||
/// ComputeShader asset
|
||||
/// </summary>
|
||||
ComputeShader,
|
||||
|
||||
// Mesh
|
||||
/// <summary>
|
||||
/// Mesh, often a subObject of a model asset
|
||||
/// </summary>
|
||||
Mesh,
|
||||
|
||||
// Texture
|
||||
/// <summary>
|
||||
/// Generic Texture asset
|
||||
/// </summary>
|
||||
Texture,
|
||||
|
||||
/// <summary>
|
||||
/// 2D image texture asset
|
||||
/// </summary>
|
||||
Texture2D,
|
||||
|
||||
/// <summary>
|
||||
/// Texture3D asset
|
||||
/// </summary>
|
||||
Texture3D,
|
||||
|
||||
/// <summary>
|
||||
/// Sprite Object, often a subObject to a Texture or SpriteAtlas
|
||||
/// </summary>
|
||||
Sprite,
|
||||
|
||||
// Scriptable Object
|
||||
/// <summary>
|
||||
/// ScriptableObject asset
|
||||
/// </summary>
|
||||
ScriptableObject,
|
||||
|
||||
// Prefab
|
||||
/// <summary>
|
||||
/// Prefab asset
|
||||
/// </summary>
|
||||
Prefab,
|
||||
|
||||
/// <summary>
|
||||
/// Special prefab type for Imported model assets
|
||||
/// </summary>
|
||||
Model,
|
||||
|
||||
// Material
|
||||
/// <summary>
|
||||
/// Rendering Material asset
|
||||
/// </summary>
|
||||
Material,
|
||||
|
||||
/// <summary>
|
||||
/// PhysicsMaterial asset
|
||||
/// </summary>
|
||||
PhysicsMaterial,
|
||||
|
||||
/// <summary>
|
||||
/// PhysicalMaterial2D asset
|
||||
/// </summary>
|
||||
PhysicsMaterial2D,
|
||||
|
||||
// Other Assets
|
||||
/// <summary>
|
||||
/// TextAsset
|
||||
/// </summary>
|
||||
TextAsset,
|
||||
|
||||
// Scene
|
||||
/// <summary>
|
||||
/// Scene asset
|
||||
/// </summary>
|
||||
Scene,
|
||||
|
||||
// Serialize Content -> combined into Scene, Prefab, Scriptable Object
|
||||
/// <summary>
|
||||
/// GameObject, can be a Prefab or Scene subObject
|
||||
/// </summary>
|
||||
GameObject,
|
||||
|
||||
/// <summary>
|
||||
/// Generic Scene Object that has an undefined AssetType
|
||||
/// </summary>
|
||||
SceneObject,
|
||||
|
||||
/// <summary>
|
||||
/// MonoBehaviour scripts
|
||||
/// </summary>
|
||||
MonoBehaviour,
|
||||
|
||||
/// <summary>
|
||||
/// Components on a GameObject not of MonoBehaviour type
|
||||
/// </summary>
|
||||
Component,
|
||||
|
||||
/// <summary>
|
||||
/// MonoScript object
|
||||
/// </summary>
|
||||
MonoScript,
|
||||
|
||||
// Scene Objects that are parsed from string by the scene object type path
|
||||
/// <summary>
|
||||
/// Cubemap scene Object
|
||||
/// </summary>
|
||||
Cubemap,
|
||||
|
||||
/// <summary>
|
||||
/// Scene Camera component
|
||||
/// </summary>
|
||||
Camera,
|
||||
|
||||
/// <summary>
|
||||
/// Scene AudioListener component
|
||||
/// </summary>
|
||||
AudioListener,
|
||||
|
||||
/// <summary>
|
||||
/// Scene Light component
|
||||
/// </summary>
|
||||
Light,
|
||||
|
||||
/// <summary>
|
||||
/// Scene NavMeshSettings Object
|
||||
/// </summary>
|
||||
NavMeshSettings,
|
||||
|
||||
/// <summary>
|
||||
/// Scene RenderSettings Object
|
||||
/// </summary>
|
||||
RenderSettings,
|
||||
|
||||
/// <summary>
|
||||
/// Scene LightmapSettings Object
|
||||
/// </summary>
|
||||
LightmapSettings,
|
||||
|
||||
/// <summary>
|
||||
/// Scene Transform component
|
||||
/// </summary>
|
||||
Transform,
|
||||
|
||||
/// <summary>
|
||||
/// Scene MeshRenderer component
|
||||
/// </summary>
|
||||
MeshRenderer,
|
||||
|
||||
/// <summary>
|
||||
/// Scene MeshFilter component
|
||||
/// </summary>
|
||||
MeshFilter,
|
||||
|
||||
/// <summary>
|
||||
/// Scene BoxCollider2D component
|
||||
/// </summary>
|
||||
BoxCollider2D,
|
||||
|
||||
/// <summary>
|
||||
/// Scene BoxCollider component
|
||||
/// </summary>
|
||||
BoxCollider,
|
||||
|
||||
/// <summary>
|
||||
/// Scene SphereCollider component
|
||||
/// </summary>
|
||||
SphereCollider,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Type of Addressables build
|
||||
/// </summary>
|
||||
public enum BuildType
|
||||
{
|
||||
/// <summary>
|
||||
/// Was made with an Addressables build made for new Player builds
|
||||
/// </summary>
|
||||
NewBuild = 0,
|
||||
|
||||
/// <summary>
|
||||
/// Was made with an Addressables update build, for a previous new build
|
||||
/// </summary>
|
||||
UpdateBuild
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Bundle status after an update build
|
||||
/// </summary>
|
||||
public enum BundleBuildStatus
|
||||
{
|
||||
/// <summary>
|
||||
/// Asset bundle is newly created for this build
|
||||
/// </summary>
|
||||
New = 0,
|
||||
|
||||
/// <summary>
|
||||
/// Asset bundle has been modified (Remote bundle expected)
|
||||
/// </summary>
|
||||
Modified,
|
||||
|
||||
/// <summary>
|
||||
/// Prevent updates, updated Asset bundle has been modified and reverted to previous details
|
||||
/// </summary>
|
||||
ModifiedUpdatePrevented,
|
||||
|
||||
/// <summary>
|
||||
/// Asset bundle was not modified and data remains the same
|
||||
/// </summary>
|
||||
Unmodified
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 1d660cd53240140bd9d3975354f1fae0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,153 @@
|
|||
using System.Collections;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEditor.AddressableAssets.Settings;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityEditor.AddressableAssets.Build.Layout
|
||||
{
|
||||
/// <summary>
|
||||
/// Helper methods for gathering data about a build layout.
|
||||
/// </summary>
|
||||
public class BuildLayoutHelpers
|
||||
{
|
||||
/// <summary>
|
||||
/// Gather a list of Explicit Assets defined in a BuildLayout
|
||||
/// </summary>
|
||||
/// <param name="layout">The BuildLayout generated during a build</param>
|
||||
/// <returns>A list of ExplicitAsset data.</returns>
|
||||
public static IEnumerable<BuildLayout.ExplicitAsset> EnumerateAssets(BuildLayout layout)
|
||||
{
|
||||
return EnumerateBundles(layout).SelectMany(b => b.Files).SelectMany(f => f.Assets);
|
||||
}
|
||||
|
||||
internal static IEnumerable<BuildLayout.DataFromOtherAsset> EnumerateImplicitAssets(BuildLayout layout)
|
||||
{
|
||||
return EnumerateBundles(layout).SelectMany(b => b.Files).SelectMany(f => f.Assets).SelectMany(a => a.InternalReferencedOtherAssets);
|
||||
}
|
||||
|
||||
internal static IEnumerable<BuildLayout.DataFromOtherAsset> EnumerateImplicitAssets(BuildLayout.Bundle bundle)
|
||||
{
|
||||
return bundle.Files.SelectMany(f => f.OtherAssets);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gather a list of Explicit Assets defined in a Bundle
|
||||
/// </summary>
|
||||
/// <param name="bundle">The Bundle data generated during a build</param>
|
||||
/// <returns>A list of ExplicitAssets defined in the Bundle</returns>
|
||||
public static IEnumerable<BuildLayout.ExplicitAsset> EnumerateAssets(BuildLayout.Bundle bundle)
|
||||
{
|
||||
return bundle.Files.SelectMany(f => f.Assets);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gather a list of Bundle data defined in a BuildLayout
|
||||
/// </summary>
|
||||
/// <param name="layout">The BuildLayout generated during a build</param>
|
||||
/// <returns>A list of the Bundle data defined in a BuildLayout</returns>
|
||||
public static IEnumerable<BuildLayout.Bundle> EnumerateBundles(BuildLayout layout)
|
||||
{
|
||||
foreach (BuildLayout.Bundle b in layout.BuiltInBundles)
|
||||
yield return b;
|
||||
|
||||
foreach (BuildLayout.Bundle b in layout.Groups.SelectMany(g => g.Bundles))
|
||||
yield return b;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gather a list of File data defined in a BuildLayout
|
||||
/// </summary>
|
||||
/// <param name="layout">The BuildLayout generated during a build</param>
|
||||
/// <returns>A list of File data</returns>
|
||||
public static IEnumerable<BuildLayout.File> EnumerateFiles(BuildLayout layout)
|
||||
{
|
||||
return EnumerateBundles(layout).SelectMany(b => b.Files);
|
||||
}
|
||||
|
||||
private static Dictionary<System.Type, AssetType> m_SystemTypeToAssetType = null;
|
||||
private static Dictionary<System.Type, AssetType> SystemTypeToAssetType
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_SystemTypeToAssetType == null)
|
||||
{
|
||||
m_SystemTypeToAssetType = new Dictionary<Type, AssetType>()
|
||||
{
|
||||
{ typeof(SceneAsset), AssetType.Scene }
|
||||
};
|
||||
}
|
||||
return m_SystemTypeToAssetType;
|
||||
}
|
||||
}
|
||||
|
||||
private static List<(System.Type, AssetType)> m_AssignableSystemTypeToAssetType = null;
|
||||
private static List<(System.Type, AssetType)> AssignableSystemTypeToAssetType
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_AssignableSystemTypeToAssetType == null)
|
||||
{
|
||||
m_AssignableSystemTypeToAssetType = new List<(Type, AssetType)>()
|
||||
{
|
||||
(typeof(ScriptableObject), AssetType.ScriptableObject),
|
||||
(typeof(MonoBehaviour), AssetType.MonoBehaviour),
|
||||
(typeof(Component), AssetType.Component)
|
||||
};
|
||||
}
|
||||
return m_AssignableSystemTypeToAssetType;
|
||||
}
|
||||
}
|
||||
|
||||
private static Dictionary<System.Type, AssetType> m_RuntimeSystemTypeToAssetType = null;
|
||||
private static Dictionary<System.Type, AssetType> RuntimeSystemTypeToAssetType
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_RuntimeSystemTypeToAssetType == null)
|
||||
{
|
||||
m_RuntimeSystemTypeToAssetType = new Dictionary<Type, AssetType>()
|
||||
{
|
||||
{ typeof(RuntimeAnimatorController), AssetType.AnimationController }
|
||||
};
|
||||
}
|
||||
return m_RuntimeSystemTypeToAssetType;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the enum AssetType associated with the param systemType ofType
|
||||
/// </summary>
|
||||
/// <param name="ofType">The Type of the asset</param>
|
||||
/// <returns>An AssetType or <see cref="AssetType.Other" /> if null or unknown.</returns>
|
||||
public static AssetType GetAssetType(Type ofType)
|
||||
{
|
||||
if (ofType == null)
|
||||
return AssetType.Other;
|
||||
|
||||
if (AssetType.TryParse(ofType.Name, out AssetType assetType))
|
||||
return assetType;
|
||||
|
||||
// types where the class name doesn't equal the AssetType (legacy enum values)
|
||||
if (SystemTypeToAssetType.TryGetValue(ofType, out assetType))
|
||||
return assetType;
|
||||
|
||||
foreach ((Type, AssetType) typeAssignment in AssignableSystemTypeToAssetType)
|
||||
{
|
||||
if (typeAssignment.Item1.IsAssignableFrom(ofType))
|
||||
return typeAssignment.Item2;
|
||||
}
|
||||
|
||||
ofType = AddressableAssetUtility.MapEditorTypeToRuntimeType(ofType, false);
|
||||
if (ofType == null)
|
||||
return AssetType.Other;
|
||||
if (SystemTypeToAssetType.TryGetValue(ofType, out assetType))
|
||||
return assetType;
|
||||
if (RuntimeSystemTypeToAssetType.TryGetValue(ofType, out assetType))
|
||||
return assetType;
|
||||
|
||||
return AssetType.Other;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: ac62285cba7c64612b59f2c0c4124c96
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,283 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityEditor.AddressableAssets.Build.Layout
|
||||
{
|
||||
class BuildLayoutPrinter
|
||||
{
|
||||
static public string GetFriendlySize(ulong byteSize)
|
||||
{
|
||||
string[] sizes = {"B", "KB", "MB", "GB", "TB"};
|
||||
int order = 0;
|
||||
ulong prevOrderRemainder = 0;
|
||||
while (byteSize >= 1024 && order < sizes.Length - 1)
|
||||
{
|
||||
order++;
|
||||
prevOrderRemainder = byteSize % 1024;
|
||||
byteSize = byteSize / 1024;
|
||||
}
|
||||
|
||||
double byteSizeFloat = (double)byteSize + (double)prevOrderRemainder / 1024;
|
||||
|
||||
string result = String.Format("{0:0.##}{1}", byteSizeFloat, sizes[order]);
|
||||
return result;
|
||||
}
|
||||
|
||||
class TabWriter
|
||||
{
|
||||
public StreamWriter Writer;
|
||||
private int Indentation;
|
||||
|
||||
public TabWriter(StreamWriter writer)
|
||||
{
|
||||
Writer = writer;
|
||||
}
|
||||
|
||||
class TabWriterIdentScope : IDisposable
|
||||
{
|
||||
TabWriter m_Writer;
|
||||
|
||||
public TabWriterIdentScope(TabWriter writer)
|
||||
{
|
||||
m_Writer = writer;
|
||||
writer.Indentation++;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
m_Writer.Indentation--;
|
||||
}
|
||||
}
|
||||
|
||||
public IDisposable IndentScope(string text = null)
|
||||
{
|
||||
if (text != null)
|
||||
WriteLine(text);
|
||||
return new TabWriterIdentScope(this);
|
||||
}
|
||||
|
||||
public void WriteLine(string line)
|
||||
{
|
||||
Writer.WriteLine(new String('\t', Indentation) + line);
|
||||
}
|
||||
}
|
||||
|
||||
class AttrBuilder
|
||||
{
|
||||
List<Tuple<string, string>> m_Items = new List<Tuple<string, string>>();
|
||||
|
||||
public void Add(string k, string v)
|
||||
{
|
||||
m_Items.Add(new Tuple<string, string>(k, v));
|
||||
}
|
||||
|
||||
public void AddSize(string k, ulong size)
|
||||
{
|
||||
m_Items.Add(new Tuple<string, string>(k, GetFriendlySize(size)));
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return "(" + string.Join(", ", m_Items.Select(x => $"{x.Item1}: {x.Item2}")) + ")";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void PrintAsset(TabWriter writer, BuildLayout.ExplicitAsset asset, int fileIndex)
|
||||
{
|
||||
AttrBuilder attr = new AttrBuilder();
|
||||
attr.AddSize("Total Size", asset.SerializedSize + asset.StreamedSize);
|
||||
attr.AddSize("Size from Objects", asset.SerializedSize);
|
||||
attr.AddSize("Size from Streamed Data", asset.StreamedSize);
|
||||
attr.Add("File Index", fileIndex.ToString());
|
||||
attr.Add("Addressable Name", asset.AddressableName);
|
||||
using (writer.IndentScope($"{asset.AssetPath} {attr}"))
|
||||
{
|
||||
if (asset.ExternallyReferencedAssets.Count > 0)
|
||||
{
|
||||
writer.WriteLine("External References: " + string.Join(", ", asset.ExternallyReferencedAssets.Select(x => x.AssetPath)));
|
||||
}
|
||||
|
||||
if (asset.InternalReferencedOtherAssets.Count > 0)
|
||||
{
|
||||
writer.WriteLine("Internal References: " + string.Join(", ", asset.InternalReferencedOtherAssets.Select(x => x.AssetPath)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void PrintDataFromOtherAsset(TabWriter writer, BuildLayout.DataFromOtherAsset asset)
|
||||
{
|
||||
AttrBuilder attr = new AttrBuilder();
|
||||
attr.AddSize("Size", asset.SerializedSize + asset.StreamedSize);
|
||||
attr.AddSize("Size from Objects", asset.SerializedSize);
|
||||
attr.AddSize("Size from Streamed Data", asset.StreamedSize);
|
||||
attr.Add("Object Count", asset.ObjectCount.ToString());
|
||||
using (writer.IndentScope($"{asset.AssetPath} {attr}"))
|
||||
{
|
||||
writer.WriteLine($"Referencing Assets: {string.Join(", ", asset.ReferencingAssets.Select(x => x.AssetPath))}");
|
||||
}
|
||||
}
|
||||
|
||||
static void PrintFile(TabWriter writer, BuildLayout.File file, int i)
|
||||
{
|
||||
AttrBuilder attr = new AttrBuilder();
|
||||
if (file.PreloadInfoSize > 0)
|
||||
attr.AddSize("PreloadInfoSize", (ulong)file.PreloadInfoSize);
|
||||
|
||||
attr.Add("MonoScripts", file.MonoScriptCount.ToString());
|
||||
attr.AddSize("MonoScript Size", file.MonoScriptSize);
|
||||
|
||||
using (writer.IndentScope($"File {i} {attr}"))
|
||||
{
|
||||
foreach (BuildLayout.SubFile sf in file.SubFiles)
|
||||
{
|
||||
AttrBuilder attr2 = new AttrBuilder();
|
||||
attr2.AddSize("Size", sf.Size);
|
||||
writer.WriteLine($"{sf.Name} {attr2}");
|
||||
}
|
||||
|
||||
using (writer.IndentScope($"Data From Other Assets ({file.OtherAssets.Count})"))
|
||||
{
|
||||
foreach (BuildLayout.DataFromOtherAsset otherData in file.OtherAssets)
|
||||
{
|
||||
PrintDataFromOtherAsset(writer, otherData);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void PrintArchive(TabWriter writer, BuildLayout.Bundle archive)
|
||||
{
|
||||
AttrBuilder attr = new AttrBuilder();
|
||||
attr.AddSize("Size", archive.FileSize);
|
||||
attr.Add("Compression", archive.Compression);
|
||||
|
||||
ulong bundleSize = archive.Files.First(x => x.BundleObjectInfo != null).BundleObjectInfo.Size;
|
||||
attr.AddSize("Asset Bundle Object Size", bundleSize);
|
||||
|
||||
using (writer.IndentScope($"Archive {archive.Name} {attr}"))
|
||||
{
|
||||
if (archive.Dependencies != null)
|
||||
writer.WriteLine("Bundle Dependencies: " + string.Join(", ", archive.Dependencies.Select(x => x.Name)));
|
||||
|
||||
if (archive.ExpandedDependencies != null)
|
||||
writer.WriteLine("Expanded Bundle Dependencies: " + string.Join(", ", archive.ExpandedDependencies.Select(x => x.Name)));
|
||||
|
||||
using (writer.IndentScope($"Explicit Assets"))
|
||||
{
|
||||
for (int i = 0; i < archive.Files.Count; i++)
|
||||
{
|
||||
BuildLayout.File f = archive.Files[i];
|
||||
foreach (BuildLayout.ExplicitAsset asset in f.Assets)
|
||||
{
|
||||
PrintAsset(writer, asset, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
using (writer.IndentScope($"Files:"))
|
||||
{
|
||||
for (int i = 0; i < archive.Files.Count; i++)
|
||||
PrintFile(writer, archive.Files[i], i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void PrintSchema(TabWriter writer, BuildLayout.SchemaData sd)
|
||||
{
|
||||
string text = sd.Type;
|
||||
if (sd.KvpDetails.Count > 0)
|
||||
{
|
||||
AttrBuilder attr = new AttrBuilder();
|
||||
sd.KvpDetails.ForEach(x => attr.Add(x.Item1, x.Item2));
|
||||
text += " " + attr;
|
||||
}
|
||||
|
||||
writer.WriteLine(text);
|
||||
}
|
||||
|
||||
static void PrintGroup(TabWriter writer, BuildLayout.Group grp)
|
||||
{
|
||||
int explicitAssetCount = grp.Bundles.Sum(x => x.Files.Sum(y => y.Assets.Count));
|
||||
AttrBuilder attr = new AttrBuilder();
|
||||
attr.Add("Bundles", grp.Bundles.Count.ToString());
|
||||
attr.AddSize("Total Size", (ulong)grp.Bundles.Sum(x => (long)x.FileSize));
|
||||
attr.Add("Explicit Asset Count", explicitAssetCount.ToString());
|
||||
|
||||
using (writer.IndentScope($"Group {grp.Name} {attr}"))
|
||||
{
|
||||
using (writer.IndentScope("Schemas"))
|
||||
grp.Schemas.ForEach(x => PrintSchema(writer, x));
|
||||
|
||||
foreach (BuildLayout.Bundle archive in grp.Bundles)
|
||||
PrintArchive(writer, archive);
|
||||
}
|
||||
}
|
||||
|
||||
internal static void WriteBundleLayout(Stream stream, BuildLayout layout)
|
||||
{
|
||||
using (StreamWriter sw = new StreamWriter(stream))
|
||||
{
|
||||
TabWriter writer = new TabWriter(sw);
|
||||
|
||||
writer.WriteLine("WARNING! The formatting in this file may change in future package versions.");
|
||||
writer.WriteLine($"Unity Version: {layout.UnityVersion}");
|
||||
if (!string.IsNullOrEmpty(layout.PackageVersion))
|
||||
writer.WriteLine(layout.PackageVersion);
|
||||
|
||||
WriteSummary(writer, layout);
|
||||
writer.WriteLine("");
|
||||
|
||||
|
||||
foreach (BuildLayout.Group grp in layout.Groups)
|
||||
{
|
||||
PrintGroup(writer, grp);
|
||||
}
|
||||
|
||||
using (writer.IndentScope("BuiltIn Bundles"))
|
||||
foreach (BuildLayout.Bundle b in layout.BuiltInBundles)
|
||||
PrintArchive(writer, b);
|
||||
}
|
||||
}
|
||||
|
||||
static void WriteSummary(TabWriter writer, BuildLayout layout)
|
||||
{
|
||||
int ExplicitAssetCount = 0;
|
||||
int SceneBundleCount = 0;
|
||||
int AssetBundleCount = 0;
|
||||
ulong TotalBuildSize = 0;
|
||||
ulong MonoScriptSize = 0;
|
||||
ulong BundleOverheadSize = 0;
|
||||
|
||||
foreach (BuildLayout.File f in BuildLayoutHelpers.EnumerateFiles(layout))
|
||||
{
|
||||
BundleOverheadSize += f.BundleObjectInfo != null ? f.BundleObjectInfo.Size : 0;
|
||||
MonoScriptSize += f.MonoScriptSize;
|
||||
}
|
||||
|
||||
foreach (BuildLayout.Bundle b in BuildLayoutHelpers.EnumerateBundles(layout))
|
||||
{
|
||||
bool sceneBundle = BuildLayoutHelpers.EnumerateAssets(b).FirstOrDefault(x => x.AssetPath.EndsWith(".unity", StringComparison.OrdinalIgnoreCase)) != null;
|
||||
SceneBundleCount += sceneBundle ? 1 : 0;
|
||||
AssetBundleCount += sceneBundle ? 0 : 1;
|
||||
TotalBuildSize += b.FileSize;
|
||||
}
|
||||
|
||||
ExplicitAssetCount = BuildLayoutHelpers.EnumerateAssets(layout).Count();
|
||||
|
||||
using (writer.IndentScope("Summary"))
|
||||
{
|
||||
writer.WriteLine($"Addressable Groups: {layout.Groups.Count}");
|
||||
writer.WriteLine($"Explicit Assets Addressed: {ExplicitAssetCount}");
|
||||
writer.WriteLine($"Total Bundle: {SceneBundleCount + AssetBundleCount} ({SceneBundleCount} Scene Bundles, {AssetBundleCount} Non-Scene Bundles)");
|
||||
writer.WriteLine($"Total Build Size: {GetFriendlySize(TotalBuildSize)}");
|
||||
writer.WriteLine($"Total MonoScript Size: {GetFriendlySize(MonoScriptSize)}");
|
||||
writer.WriteLine($"Total AssetBundle Object Size: {GetFriendlySize(BundleOverheadSize)}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 859e5046b2060774898d8e87f4e78761
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,210 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
namespace UnityEditor.AddressableAssets.Build.Layout
|
||||
{
|
||||
/// <summary>
|
||||
/// Data store for summary data about build content
|
||||
/// </summary>
|
||||
public struct AssetSummary
|
||||
{
|
||||
/// <summary>
|
||||
/// Type of Asset
|
||||
/// </summary>
|
||||
public AssetType AssetType;
|
||||
|
||||
/// <summary>
|
||||
/// Number of Objects build of the defined AssetType
|
||||
/// </summary>
|
||||
public int Count;
|
||||
|
||||
/// <summary>
|
||||
/// Total size of combined Objects
|
||||
/// </summary>
|
||||
public ulong SizeInBytes;
|
||||
|
||||
internal void Append(AssetSummary other)
|
||||
{
|
||||
Count += other.Count;
|
||||
SizeInBytes += other.SizeInBytes;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Data store for summary data about Bundle content
|
||||
/// </summary>
|
||||
public struct BundleSummary
|
||||
{
|
||||
/// <summary>
|
||||
/// Number of bundles built
|
||||
/// </summary>
|
||||
public int Count;
|
||||
|
||||
/// <summary>
|
||||
/// Size in bytes of bundles uncompressed
|
||||
/// </summary>
|
||||
public ulong TotalUncompressedSize;
|
||||
|
||||
/// <summary>
|
||||
/// Size in bytes of bundled compressed
|
||||
/// </summary>
|
||||
public ulong TotalCompressedSize;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Data store for Addressables build
|
||||
/// </summary>
|
||||
public class BuildLayoutSummary
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary of bundles
|
||||
/// </summary>
|
||||
public BundleSummary BundleSummary = new BundleSummary();
|
||||
|
||||
/// <summary>
|
||||
/// Summary for AssetTypes used
|
||||
/// </summary>
|
||||
public List<AssetSummary> AssetSummaries = new List<AssetSummary>();
|
||||
|
||||
/// <summary>
|
||||
/// The total number of assets in a build, including implicit assets
|
||||
/// </summary>
|
||||
internal int TotalAssetCount = 0;
|
||||
|
||||
/// <summary>
|
||||
/// The total number of explicitly added Addressable assets that were included in a build
|
||||
/// </summary>
|
||||
internal int ExplicitAssetCount = 0;
|
||||
|
||||
/// <summary>
|
||||
/// The total number of implicitly added assets that were included in a build
|
||||
/// </summary>
|
||||
internal int ImplicitAssetCount = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Generates a summary of the content used in a BuildLayout
|
||||
/// </summary>
|
||||
/// <param name="layout">BuildLayout to get a summary for</param>
|
||||
/// <returns>Summary of the BuildLayout layout</returns>
|
||||
public static BuildLayoutSummary GetSummary(BuildLayout layout)
|
||||
{
|
||||
BuildLayoutSummary summary = new BuildLayoutSummary();
|
||||
Dictionary<AssetType, ulong> sizes = new Dictionary<AssetType, ulong>();
|
||||
foreach (var group in layout.Groups)
|
||||
{
|
||||
foreach (var bundle in group.Bundles)
|
||||
{
|
||||
summary.BundleSummary.TotalCompressedSize += bundle.FileSize;
|
||||
summary.BundleSummary.TotalUncompressedSize += bundle.UncompressedFileSize;
|
||||
summary.BundleSummary.Count++;
|
||||
|
||||
foreach (var file in bundle.Files)
|
||||
{
|
||||
summary.TotalAssetCount += file.Assets.Count + file.OtherAssets.Count;
|
||||
summary.ExplicitAssetCount += file.Assets.Count;
|
||||
summary.ImplicitAssetCount += file.OtherAssets.Count;
|
||||
|
||||
foreach (var asset in file.Assets)
|
||||
AppendObjectsToSummary(asset.MainAssetType, asset.SerializedSize + asset.StreamedSize, asset.Objects, summary.AssetSummaries);
|
||||
foreach (var asset in file.OtherAssets)
|
||||
AppendObjectsToSummary(asset.MainAssetType, asset.SerializedSize + asset.StreamedSize, asset.Objects, summary.AssetSummaries);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return summary;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Generates a summary of the content used in a BuildLayout, minus the asset type data.
|
||||
/// </summary>
|
||||
/// <param name="layout"></param>
|
||||
/// <returns></returns>
|
||||
|
||||
internal static BuildLayoutSummary GetSummaryWithoutAssetTypes(BuildLayout layout)
|
||||
{
|
||||
BuildLayoutSummary summary = new BuildLayoutSummary();
|
||||
foreach (var group in layout.Groups)
|
||||
{
|
||||
foreach (var bundle in group.Bundles)
|
||||
{
|
||||
summary.BundleSummary.TotalCompressedSize += bundle.FileSize;
|
||||
summary.BundleSummary.TotalUncompressedSize += bundle.UncompressedFileSize;
|
||||
summary.BundleSummary.Count++;
|
||||
|
||||
foreach (var file in bundle.Files)
|
||||
{
|
||||
summary.TotalAssetCount += file.Assets.Count + file.OtherAssets.Count;
|
||||
summary.ExplicitAssetCount += file.Assets.Count;
|
||||
summary.ImplicitAssetCount += file.OtherAssets.Count;
|
||||
}
|
||||
}
|
||||
}
|
||||
return summary;
|
||||
}
|
||||
|
||||
private static void AppendObjectsToSummary(AssetType mainAssetType, ulong overallSize, List<BuildLayout.ObjectData> subObjects, List<AssetSummary> assetSummariesOut)
|
||||
{
|
||||
// for Scene Assets take the accumulation of Objects for overall Scene size
|
||||
if (mainAssetType == AssetType.Scene)
|
||||
AddObjectToSummary(AssetType.Scene, overallSize, assetSummariesOut);
|
||||
|
||||
// for prefabs accumulate general objects like GameObject and Transform as Prefab
|
||||
else if (mainAssetType == AssetType.Prefab || mainAssetType == AssetType.Model)
|
||||
{
|
||||
ulong serializedSize = 0;
|
||||
ulong streamedSize = 0;
|
||||
ulong size = 0;
|
||||
|
||||
foreach (var objectData in subObjects)
|
||||
{
|
||||
if (objectData.AssetType == AssetType.Other ||
|
||||
objectData.AssetType == AssetType.GameObject ||
|
||||
objectData.AssetType == AssetType.Component ||
|
||||
objectData.AssetType == AssetType.MonoBehaviour )
|
||||
{
|
||||
serializedSize += objectData.SerializedSize;
|
||||
streamedSize += objectData.StreamedSize;
|
||||
}
|
||||
else
|
||||
{
|
||||
AddObjectToSummary(objectData.AssetType, objectData.SerializedSize + objectData.StreamedSize, assetSummariesOut);
|
||||
}
|
||||
}
|
||||
|
||||
size = serializedSize + streamedSize;
|
||||
if (size > 0)
|
||||
AddObjectToSummary(AssetType.Prefab, size, assetSummariesOut);
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (BuildLayout.ObjectData objectData in subObjects)
|
||||
{
|
||||
AddObjectToSummary(objectData.AssetType, objectData.SerializedSize + objectData.StreamedSize, assetSummariesOut);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void AddObjectToSummary(AssetType assetType, ulong size, List<AssetSummary> assetSummaries)
|
||||
{
|
||||
AssetSummary summary = new AssetSummary()
|
||||
{
|
||||
AssetType = assetType,
|
||||
Count = 1,
|
||||
SizeInBytes = size
|
||||
};
|
||||
|
||||
for(int i=0; i<assetSummaries.Count; ++i)
|
||||
{
|
||||
if (assetSummaries[i].AssetType == assetType)
|
||||
{
|
||||
summary.Count = assetSummaries[i].Count + 1;
|
||||
summary.SizeInBytes = assetSummaries[i].SizeInBytes + size;
|
||||
assetSummaries[i] = summary;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
assetSummaries.Add(summary);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: f9db3cbcec3734a2498a530fa229403e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Loading…
Add table
Add a link
Reference in a new issue