初始化
This commit is contained in:
@@ -0,0 +1,236 @@
|
||||
using System;
|
||||
|
||||
namespace BuildReportTool
|
||||
{
|
||||
public static partial class AssetListUtility
|
||||
{
|
||||
public static void SortAssetList(BuildReportTool.SizePart[] assetList, BuildReportTool.AssetList.SortType sortType, BuildReportTool.AssetList.SortOrder sortOrder)
|
||||
{
|
||||
switch (sortType)
|
||||
{
|
||||
case BuildReportTool.AssetList.SortType.RawSize:
|
||||
SortRawSize(assetList, sortOrder);
|
||||
break;
|
||||
case BuildReportTool.AssetList.SortType.ImportedSize:
|
||||
SortImportedSize(assetList, sortOrder);
|
||||
break;
|
||||
case BuildReportTool.AssetList.SortType.ImportedSizeOrRawSize:
|
||||
SortImportedSizeOrRawSize(assetList, sortOrder);
|
||||
break;
|
||||
case BuildReportTool.AssetList.SortType.SizeBeforeBuild:
|
||||
SortSizeBeforeBuild(assetList, sortOrder);
|
||||
break;
|
||||
case BuildReportTool.AssetList.SortType.PercentSize:
|
||||
SortPercentSize(assetList, sortOrder);
|
||||
break;
|
||||
case BuildReportTool.AssetList.SortType.AssetFullPath:
|
||||
SortAssetFullPath(assetList, sortOrder);
|
||||
break;
|
||||
case BuildReportTool.AssetList.SortType.AssetFilename:
|
||||
SortAssetName(assetList, sortOrder);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void SortRawSize(BuildReportTool.SizePart[] assetList, BuildReportTool.AssetList.SortOrder sortOrder)
|
||||
{
|
||||
if (sortOrder == BuildReportTool.AssetList.SortOrder.Descending)
|
||||
{
|
||||
Array.Sort(assetList, delegate(BuildReportTool.SizePart entry1, BuildReportTool.SizePart entry2)
|
||||
{
|
||||
if (entry1.UsableSize > entry2.UsableSize) return -1;
|
||||
if (entry1.UsableSize < entry2.UsableSize) return 1;
|
||||
|
||||
// same size
|
||||
// sort by asset name for assets with same sizes
|
||||
return SortByAssetNameDescending(entry1, entry2);
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
Array.Sort(assetList, delegate(BuildReportTool.SizePart entry1, BuildReportTool.SizePart entry2)
|
||||
{
|
||||
if (entry1.UsableSize > entry2.UsableSize) return 1;
|
||||
if (entry1.UsableSize < entry2.UsableSize) return -1;
|
||||
|
||||
// same size
|
||||
// sort by asset name for assets with same sizes
|
||||
return SortByAssetNameAscending(entry1, entry2);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
static void SortImportedSizeOrRawSize(BuildReportTool.SizePart[] assetList, BuildReportTool.AssetList.SortOrder sortOrder)
|
||||
{
|
||||
if (sortOrder == BuildReportTool.AssetList.SortOrder.Descending)
|
||||
{
|
||||
Array.Sort(assetList, delegate(BuildReportTool.SizePart entry1, BuildReportTool.SizePart entry2)
|
||||
{
|
||||
if (entry1.ImportedSizeOrRawSize > entry2.ImportedSizeOrRawSize) return -1;
|
||||
if (entry1.ImportedSizeOrRawSize < entry2.ImportedSizeOrRawSize) return 1;
|
||||
|
||||
// same size
|
||||
// sort by asset name for assets with same sizes
|
||||
return SortByAssetNameDescending(entry1, entry2);
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
Array.Sort(assetList, delegate(BuildReportTool.SizePart entry1, BuildReportTool.SizePart entry2)
|
||||
{
|
||||
if (entry1.ImportedSizeOrRawSize > entry2.ImportedSizeOrRawSize) return 1;
|
||||
if (entry1.ImportedSizeOrRawSize < entry2.ImportedSizeOrRawSize) return -1;
|
||||
|
||||
// same size
|
||||
// sort by asset name for assets with same sizes
|
||||
return SortByAssetNameAscending(entry1, entry2);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
static void SortImportedSize(BuildReportTool.SizePart[] assetList, BuildReportTool.AssetList.SortOrder sortOrder)
|
||||
{
|
||||
if (sortOrder == BuildReportTool.AssetList.SortOrder.Descending)
|
||||
{
|
||||
Array.Sort(assetList, delegate(BuildReportTool.SizePart entry1, BuildReportTool.SizePart entry2)
|
||||
{
|
||||
if (entry1.ImportedSizeBytes > entry2.ImportedSizeBytes) return -1;
|
||||
if (entry1.ImportedSizeBytes < entry2.ImportedSizeBytes) return 1;
|
||||
|
||||
// same size
|
||||
// sort by asset name for assets with same sizes
|
||||
return SortByAssetNameDescending(entry1, entry2);
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
Array.Sort(assetList, delegate(BuildReportTool.SizePart entry1, BuildReportTool.SizePart entry2)
|
||||
{
|
||||
if (entry1.ImportedSizeBytes > entry2.ImportedSizeBytes) return 1;
|
||||
if (entry1.ImportedSizeBytes < entry2.ImportedSizeBytes) return -1;
|
||||
|
||||
// same size
|
||||
// sort by asset name for assets with same sizes
|
||||
return SortByAssetNameAscending(entry1, entry2);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
static void SortSizeBeforeBuild(BuildReportTool.SizePart[] assetList, BuildReportTool.AssetList.SortOrder sortOrder)
|
||||
{
|
||||
if (sortOrder == BuildReportTool.AssetList.SortOrder.Descending)
|
||||
{
|
||||
Array.Sort(assetList, delegate(BuildReportTool.SizePart entry1, BuildReportTool.SizePart entry2)
|
||||
{
|
||||
if (entry1.SizeInAssetsFolderBytes > entry2.SizeInAssetsFolderBytes) return -1;
|
||||
if (entry1.SizeInAssetsFolderBytes < entry2.SizeInAssetsFolderBytes) return 1;
|
||||
|
||||
// same size
|
||||
// sort by asset name for assets with same sizes
|
||||
return SortByAssetNameDescending(entry1, entry2);
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
Array.Sort(assetList, delegate(BuildReportTool.SizePart entry1, BuildReportTool.SizePart entry2)
|
||||
{
|
||||
if (entry1.SizeInAssetsFolderBytes > entry2.SizeInAssetsFolderBytes) return 1;
|
||||
if (entry1.SizeInAssetsFolderBytes < entry2.SizeInAssetsFolderBytes) return -1;
|
||||
|
||||
// same size
|
||||
// sort by asset name for assets with same sizes
|
||||
return SortByAssetNameAscending(entry1, entry2);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
static void SortPercentSize(BuildReportTool.SizePart[] assetList, BuildReportTool.AssetList.SortOrder sortOrder)
|
||||
{
|
||||
if (sortOrder == BuildReportTool.AssetList.SortOrder.Descending)
|
||||
{
|
||||
Array.Sort(assetList, delegate(BuildReportTool.SizePart entry1, BuildReportTool.SizePart entry2)
|
||||
{
|
||||
if (entry1.Percentage > entry2.Percentage) return -1;
|
||||
if (entry1.Percentage < entry2.Percentage) return 1;
|
||||
|
||||
// same percent
|
||||
// sort by asset name for assets with same percent
|
||||
return SortByAssetFullPathDescending(entry1, entry2);
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
Array.Sort(assetList, delegate(BuildReportTool.SizePart entry1, BuildReportTool.SizePart entry2)
|
||||
{
|
||||
if (entry1.Percentage > entry2.Percentage) return 1;
|
||||
if (entry1.Percentage < entry2.Percentage) return -1;
|
||||
|
||||
// same size
|
||||
// sort by asset name for assets with same sizes
|
||||
return SortByAssetFullPathAscending(entry1, entry2);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
static void SortAssetFullPath(BuildReportTool.SizePart[] assetList, BuildReportTool.AssetList.SortOrder sortOrder)
|
||||
{
|
||||
if (sortOrder == BuildReportTool.AssetList.SortOrder.Descending)
|
||||
{
|
||||
Array.Sort(assetList, SortByAssetFullPathDescending);
|
||||
}
|
||||
else
|
||||
{
|
||||
Array.Sort(assetList, SortByAssetFullPathAscending);
|
||||
}
|
||||
}
|
||||
|
||||
static int SortByAssetFullPathDescending(BuildReportTool.SizePart entry1, BuildReportTool.SizePart entry2)
|
||||
{
|
||||
int result = string.Compare(entry1.Name, entry2.Name, StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static int SortByAssetFullPathAscending(BuildReportTool.SizePart entry1, BuildReportTool.SizePart entry2)
|
||||
{
|
||||
int result = string.Compare(entry1.Name, entry2.Name, StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
// invert the result
|
||||
if (result == 1) return -1;
|
||||
if (result == -1) return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void SortAssetName(BuildReportTool.SizePart[] assetList, BuildReportTool.AssetList.SortOrder sortOrder)
|
||||
{
|
||||
if (sortOrder == BuildReportTool.AssetList.SortOrder.Descending)
|
||||
{
|
||||
Array.Sort(assetList, SortByAssetNameDescending);
|
||||
}
|
||||
else
|
||||
{
|
||||
Array.Sort(assetList, SortByAssetNameAscending);
|
||||
}
|
||||
}
|
||||
|
||||
static int SortByAssetNameDescending(BuildReportTool.SizePart entry1, BuildReportTool.SizePart entry2)
|
||||
{
|
||||
int result = string.Compare(entry1.Name.GetFileNameOnly(), entry2.Name.GetFileNameOnly(),
|
||||
StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static int SortByAssetNameAscending(BuildReportTool.SizePart entry1, BuildReportTool.SizePart entry2)
|
||||
{
|
||||
int result = string.Compare(entry1.Name.GetFileNameOnly(), entry2.Name.GetFileNameOnly(),
|
||||
StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
// invert the result
|
||||
if (result == 1) return -1;
|
||||
if (result == -1) return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 79890ab40b491994db602a062a793219
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,71 @@
|
||||
using System;
|
||||
|
||||
namespace BuildReportTool
|
||||
{
|
||||
public static partial class AssetListUtility
|
||||
{
|
||||
public static void SortAssetList(BuildReportTool.SizePart[] assetList, BuildReportTool.MeshData meshData, MeshData.DataId meshSortType, BuildReportTool.AssetList.SortOrder sortOrder)
|
||||
{
|
||||
switch (meshSortType)
|
||||
{
|
||||
case BuildReportTool.MeshData.DataId.MeshFilterCount:
|
||||
SortMeshData(assetList, meshData, sortOrder, entry => entry.MeshFilterCount);
|
||||
break;
|
||||
case BuildReportTool.MeshData.DataId.SkinnedMeshRendererCount:
|
||||
SortMeshData(assetList, meshData, sortOrder, entry => entry.SkinnedMeshRendererCount);
|
||||
break;
|
||||
case BuildReportTool.MeshData.DataId.SubMeshCount:
|
||||
SortMeshData(assetList, meshData, sortOrder, entry => entry.SubMeshCount);
|
||||
break;
|
||||
case BuildReportTool.MeshData.DataId.VertexCount:
|
||||
SortMeshData(assetList, meshData, sortOrder, entry => entry.VertexCount);
|
||||
break;
|
||||
case BuildReportTool.MeshData.DataId.TriangleCount:
|
||||
SortMeshData(assetList, meshData, sortOrder, entry => entry.TriangleCount);
|
||||
break;
|
||||
case BuildReportTool.MeshData.DataId.AnimationType:
|
||||
SortMeshData(assetList, meshData, sortOrder, entry => entry.AnimationType);
|
||||
break;
|
||||
case BuildReportTool.MeshData.DataId.AnimationClipCount:
|
||||
SortMeshData(assetList, meshData, sortOrder, entry => entry.AnimationClipCount);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void SortMeshData(BuildReportTool.SizePart[] assetList, BuildReportTool.MeshData meshData, BuildReportTool.AssetList.SortOrder sortOrder, Func<BuildReportTool.MeshData.Entry, int> func)
|
||||
{
|
||||
var meshEntries = meshData.GetMeshData();
|
||||
|
||||
for (int n = 0; n < assetList.Length; ++n)
|
||||
{
|
||||
int intValue = 0;
|
||||
if (meshEntries.ContainsKey(assetList[n].Name))
|
||||
{
|
||||
intValue = func(meshEntries[assetList[n].Name]);
|
||||
}
|
||||
|
||||
assetList[n].SetIntAuxData(intValue);
|
||||
}
|
||||
|
||||
SortByInt(assetList, sortOrder);
|
||||
}
|
||||
|
||||
static void SortMeshData(BuildReportTool.SizePart[] assetList, BuildReportTool.MeshData meshData, BuildReportTool.AssetList.SortOrder sortOrder, Func<BuildReportTool.MeshData.Entry, string> func)
|
||||
{
|
||||
var meshEntries = meshData.GetMeshData();
|
||||
|
||||
for (int n = 0; n < assetList.Length; ++n)
|
||||
{
|
||||
string textData = null;
|
||||
if (meshEntries.ContainsKey(assetList[n].Name))
|
||||
{
|
||||
textData = func(meshEntries[assetList[n].Name]);
|
||||
}
|
||||
|
||||
assetList[n].SetTextAuxData(textData);
|
||||
}
|
||||
|
||||
SortByText(assetList, sortOrder);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f73334247e6cf5545871508d6e601fc5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,53 @@
|
||||
using System;
|
||||
|
||||
namespace BuildReportTool
|
||||
{
|
||||
public static partial class AssetListUtility
|
||||
{
|
||||
public static void SortAssetList(BuildReportTool.SizePart[] assetList, BuildReportTool.PrefabData prefabData, PrefabData.DataId prefabSortType, BuildReportTool.AssetList.SortOrder sortOrder)
|
||||
{
|
||||
switch (prefabSortType)
|
||||
{
|
||||
case BuildReportTool.PrefabData.DataId.ContributeGI:
|
||||
SortPrefabData(assetList, prefabData, sortOrder, entry => entry.ContributeGIValue);
|
||||
break;
|
||||
case BuildReportTool.PrefabData.DataId.BatchingStatic:
|
||||
SortPrefabData(assetList, prefabData, sortOrder, entry => entry.BatchingStaticValue);
|
||||
break;
|
||||
case BuildReportTool.PrefabData.DataId.ReflectionProbeStatic:
|
||||
SortPrefabData(assetList, prefabData, sortOrder, entry => entry.ReflectionProbeStaticValue);
|
||||
break;
|
||||
case BuildReportTool.PrefabData.DataId.OccluderStatic:
|
||||
SortPrefabData(assetList, prefabData, sortOrder, entry => entry.OccluderStaticValue);
|
||||
break;
|
||||
case BuildReportTool.PrefabData.DataId.OccludeeStatic:
|
||||
SortPrefabData(assetList, prefabData, sortOrder, entry => entry.OccludeeStaticValue);
|
||||
break;
|
||||
case BuildReportTool.PrefabData.DataId.NavigationStatic:
|
||||
SortPrefabData(assetList, prefabData, sortOrder, entry => entry.NavigationStaticValue);
|
||||
break;
|
||||
case BuildReportTool.PrefabData.DataId.OffMeshLinkGeneration:
|
||||
SortPrefabData(assetList, prefabData, sortOrder, entry => entry.OffMeshLinkGenerationValue);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void SortPrefabData(BuildReportTool.SizePart[] assetList, BuildReportTool.PrefabData prefabData, BuildReportTool.AssetList.SortOrder sortOrder, Func<BuildReportTool.PrefabData.Entry, int> func)
|
||||
{
|
||||
var prefabEntries = prefabData.GetPrefabData();
|
||||
|
||||
for (int n = 0; n < assetList.Length; ++n)
|
||||
{
|
||||
int intValue = 0;
|
||||
if (prefabEntries.ContainsKey(assetList[n].Name))
|
||||
{
|
||||
intValue = func(prefabEntries[assetList[n].Name]);
|
||||
}
|
||||
|
||||
assetList[n].SetIntAuxData(intValue);
|
||||
}
|
||||
|
||||
SortByInt(assetList, sortOrder);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9b43049560f4da54c8419cb9700ba7f9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,466 @@
|
||||
using System;
|
||||
|
||||
namespace BuildReportTool
|
||||
{
|
||||
public static partial class AssetListUtility
|
||||
{
|
||||
public static void SortAssetList(BuildReportTool.SizePart[] assetList, BuildReportTool.TextureData textureData, TextureData.DataId textureSortType, BuildReportTool.AssetList.SortOrder sortOrder)
|
||||
{
|
||||
switch (textureSortType)
|
||||
{
|
||||
case BuildReportTool.TextureData.DataId.TextureType:
|
||||
SortTextureData(assetList, textureData, sortOrder, entry => entry.TextureType);
|
||||
break;
|
||||
case BuildReportTool.TextureData.DataId.IsSRGB:
|
||||
SortTextureData(assetList, textureData, sortOrder, entry => entry.IsSRGB);
|
||||
break;
|
||||
case BuildReportTool.TextureData.DataId.AlphaSource:
|
||||
SortTextureData(assetList, textureData, sortOrder, entry => entry.AlphaSource);
|
||||
break;
|
||||
case BuildReportTool.TextureData.DataId.AlphaIsTransparency:
|
||||
SortTextureData(assetList, textureData, sortOrder, entry => entry.AlphaIsTransparency);
|
||||
break;
|
||||
case BuildReportTool.TextureData.DataId.IgnorePngGamma:
|
||||
SortTextureData(assetList, textureData, sortOrder, entry => entry.IgnorePngGamma);
|
||||
break;
|
||||
case BuildReportTool.TextureData.DataId.NPotScale:
|
||||
SortNPotScale(assetList, textureData, sortOrder);
|
||||
break;
|
||||
case BuildReportTool.TextureData.DataId.IsReadable:
|
||||
SortTextureData(assetList, textureData, sortOrder, entry => entry.IsReadable);
|
||||
break;
|
||||
case BuildReportTool.TextureData.DataId.MipMapGenerated:
|
||||
SortTextureData(assetList, textureData, sortOrder, entry => entry.MipMapGenerated);
|
||||
break;
|
||||
case BuildReportTool.TextureData.DataId.MipMapFilter:
|
||||
SortTextureData(assetList, textureData, sortOrder, entry => entry.MipMapFilter);
|
||||
break;
|
||||
case BuildReportTool.TextureData.DataId.StreamingMipMaps:
|
||||
SortTextureData(assetList, textureData, sortOrder, entry => entry.StreamingMipMaps);
|
||||
break;
|
||||
case BuildReportTool.TextureData.DataId.BorderMipMaps:
|
||||
SortTextureData(assetList, textureData, sortOrder, entry => entry.BorderMipMaps);
|
||||
break;
|
||||
case BuildReportTool.TextureData.DataId.PreserveCoverageMipMaps:
|
||||
SortTextureData(assetList, textureData, sortOrder, entry => entry.PreserveCoverageMipMaps);
|
||||
break;
|
||||
case BuildReportTool.TextureData.DataId.FadeOutMipMaps:
|
||||
SortTextureData(assetList, textureData, sortOrder, entry => entry.FadeOutMipMaps);
|
||||
break;
|
||||
case BuildReportTool.TextureData.DataId.SpriteImportMode:
|
||||
SortTextureData(assetList, textureData, sortOrder, entry => entry.SpriteImportMode);
|
||||
break;
|
||||
case BuildReportTool.TextureData.DataId.SpritePackingTag:
|
||||
SortTextureData(assetList, textureData, sortOrder, entry => entry.SpritePackingTag);
|
||||
break;
|
||||
case BuildReportTool.TextureData.DataId.SpritePixelsPerUnit:
|
||||
SortTextureData(assetList, textureData, sortOrder, entry => entry.SpritePixelsPerUnit);
|
||||
break;
|
||||
case BuildReportTool.TextureData.DataId.QualifiesForSpritePacking:
|
||||
SortTextureData(assetList, textureData, sortOrder, entry => entry.QualifiesForSpritePacking);
|
||||
break;
|
||||
case BuildReportTool.TextureData.DataId.WrapMode:
|
||||
SortTextureData(assetList, textureData, sortOrder, entry => entry.WrapMode);
|
||||
break;
|
||||
case BuildReportTool.TextureData.DataId.WrapModeU:
|
||||
SortTextureData(assetList, textureData, sortOrder, entry => entry.WrapModeU);
|
||||
break;
|
||||
case BuildReportTool.TextureData.DataId.WrapModeV:
|
||||
SortTextureData(assetList, textureData, sortOrder, entry => entry.WrapModeV);
|
||||
break;
|
||||
case BuildReportTool.TextureData.DataId.WrapModeW:
|
||||
SortTextureData(assetList, textureData, sortOrder, entry => entry.WrapModeW);
|
||||
break;
|
||||
case BuildReportTool.TextureData.DataId.FilterMode:
|
||||
SortTextureData(assetList, textureData, sortOrder, entry => entry.FilterMode);
|
||||
break;
|
||||
case BuildReportTool.TextureData.DataId.AnisoLevel:
|
||||
SortTextureData(assetList, textureData, sortOrder, entry => entry.AnisoLevel);
|
||||
break;
|
||||
case BuildReportTool.TextureData.DataId.MaxTextureSize:
|
||||
SortTextureData(assetList, textureData, sortOrder, entry => entry.GetShownMaxTextureSize());
|
||||
break;
|
||||
case BuildReportTool.TextureData.DataId.TextureResizeAlgorithm:
|
||||
SortTextureData(assetList, textureData, sortOrder, entry => entry.GetShownTextureResizeAlgorithm());
|
||||
break;
|
||||
case BuildReportTool.TextureData.DataId.TextureFormat:
|
||||
SortTextureData(assetList, textureData, sortOrder, entry => entry.GetShownTextureFormat());
|
||||
break;
|
||||
case BuildReportTool.TextureData.DataId.CompressionType:
|
||||
SortTextureData(assetList, textureData, sortOrder, entry => entry.GetShownCompressionType());
|
||||
break;
|
||||
case BuildReportTool.TextureData.DataId.CompressionIsCrunched:
|
||||
SortTextureData(assetList, textureData, sortOrder, entry => entry.GetShownCompressionIsCrunched());
|
||||
break;
|
||||
case BuildReportTool.TextureData.DataId.CompressionQuality:
|
||||
SortTextureData(assetList, textureData, sortOrder, entry => entry.GetShownCompressionQuality());
|
||||
break;
|
||||
case BuildReportTool.TextureData.DataId.ImportedWidthAndHeight:
|
||||
SortTextureData(assetList, textureData, sortOrder, entry => entry.GetImportedPixelCount());
|
||||
break;
|
||||
case BuildReportTool.TextureData.DataId.RealWidthAndHeight:
|
||||
SortTextureData(assetList, textureData, sortOrder, entry => entry.GetRealPixelCount());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static int CompareNPotScale(string nPotScale1, string nPotScale2)
|
||||
{
|
||||
var nPotScale1IsNoneNot = nPotScale1 == BuildReportTool.TextureData.NPOT_SCALE_NONE_NOT_POT;
|
||||
var nPotScale2IsNoneNot = nPotScale1 == BuildReportTool.TextureData.NPOT_SCALE_NONE_NOT_POT;
|
||||
|
||||
if (nPotScale1IsNoneNot && !nPotScale2IsNoneNot)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
if (!nPotScale1IsNoneNot && nPotScale2IsNoneNot)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
return string.Compare(nPotScale1, nPotScale2, StringComparison.Ordinal);
|
||||
}
|
||||
|
||||
// =============================================================================================================
|
||||
|
||||
static void SortByInt(BuildReportTool.SizePart[] assetList, BuildReportTool.AssetList.SortOrder sortOrder)
|
||||
{
|
||||
if (sortOrder == BuildReportTool.AssetList.SortOrder.Descending)
|
||||
{
|
||||
Array.Sort(assetList, delegate(BuildReportTool.SizePart entry1, BuildReportTool.SizePart entry2)
|
||||
{
|
||||
int sortResult = entry2.GetIntAuxData().CompareTo(entry1.GetIntAuxData());
|
||||
if (sortResult != 0)
|
||||
{
|
||||
return sortResult;
|
||||
}
|
||||
|
||||
// same texture data
|
||||
// sort by asset size for assets with texture data
|
||||
if (entry1.UsableSize > entry2.UsableSize) return -1;
|
||||
if (entry1.UsableSize < entry2.UsableSize) return 1;
|
||||
|
||||
// same size
|
||||
// sort by asset name for assets with same sizes
|
||||
return SortByAssetNameDescending(entry1, entry2);
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
Array.Sort(assetList, delegate(BuildReportTool.SizePart entry1, BuildReportTool.SizePart entry2)
|
||||
{
|
||||
int sortResult = entry1.GetIntAuxData().CompareTo(entry2.GetIntAuxData());
|
||||
if (sortResult != 0)
|
||||
{
|
||||
return sortResult;
|
||||
}
|
||||
|
||||
// same texture data
|
||||
// sort by asset size for assets with same texture data
|
||||
if (entry1.UsableSize > entry2.UsableSize) return 1;
|
||||
if (entry1.UsableSize < entry2.UsableSize) return -1;
|
||||
|
||||
// same size
|
||||
// sort by asset name for assets with same sizes
|
||||
return SortByAssetNameAscending(entry1, entry2);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
static void SortByFloat(BuildReportTool.SizePart[] assetList, BuildReportTool.AssetList.SortOrder sortOrder)
|
||||
{
|
||||
if (sortOrder == BuildReportTool.AssetList.SortOrder.Descending)
|
||||
{
|
||||
Array.Sort(assetList, delegate(BuildReportTool.SizePart entry1, BuildReportTool.SizePart entry2)
|
||||
{
|
||||
int sortResult = entry1.GetFloatAuxData().CompareTo(entry2.GetFloatAuxData());
|
||||
if (sortResult != 0)
|
||||
{
|
||||
return sortResult;
|
||||
}
|
||||
|
||||
// same texture data
|
||||
// sort by asset size for assets with texture data
|
||||
if (entry1.UsableSize > entry2.UsableSize) return -1;
|
||||
if (entry1.UsableSize < entry2.UsableSize) return 1;
|
||||
|
||||
// same size
|
||||
// sort by asset name for assets with same sizes
|
||||
return SortByAssetNameDescending(entry1, entry2);
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
Array.Sort(assetList, delegate(BuildReportTool.SizePart entry1, BuildReportTool.SizePart entry2)
|
||||
{
|
||||
int sortResult = entry2.GetFloatAuxData().CompareTo(entry1.GetFloatAuxData());
|
||||
if (sortResult != 0)
|
||||
{
|
||||
return sortResult;
|
||||
}
|
||||
|
||||
// same texture data
|
||||
// sort by asset size for assets with same texture data
|
||||
if (entry1.UsableSize > entry2.UsableSize) return 1;
|
||||
if (entry1.UsableSize < entry2.UsableSize) return -1;
|
||||
|
||||
// same size
|
||||
// sort by asset name for assets with same sizes
|
||||
return SortByAssetNameAscending(entry1, entry2);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
static void SortByText(BuildReportTool.SizePart[] assetList, BuildReportTool.AssetList.SortOrder sortOrder)
|
||||
{
|
||||
if (sortOrder == BuildReportTool.AssetList.SortOrder.Descending)
|
||||
{
|
||||
Array.Sort(assetList, delegate(BuildReportTool.SizePart entry1, BuildReportTool.SizePart entry2)
|
||||
{
|
||||
int sortTextureTypeResult = string.Compare(entry1.GetTextAuxData(), entry2.GetTextAuxData(), StringComparison.OrdinalIgnoreCase);
|
||||
if (sortTextureTypeResult != 0)
|
||||
{
|
||||
return sortTextureTypeResult;
|
||||
}
|
||||
|
||||
// same texture type
|
||||
// sort by asset size for assets with same texture types
|
||||
if (entry1.UsableSize > entry2.UsableSize) return -1;
|
||||
if (entry1.UsableSize < entry2.UsableSize) return 1;
|
||||
|
||||
// same size
|
||||
// sort by asset name for assets with same sizes
|
||||
return SortByAssetNameDescending(entry1, entry2);
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
Array.Sort(assetList, delegate(BuildReportTool.SizePart entry1, BuildReportTool.SizePart entry2)
|
||||
{
|
||||
int sortTextureTypeResult = string.Compare(entry2.GetTextAuxData(), entry1.GetTextAuxData(), StringComparison.OrdinalIgnoreCase);
|
||||
if (sortTextureTypeResult != 0)
|
||||
{
|
||||
return sortTextureTypeResult;
|
||||
}
|
||||
|
||||
// same texture type
|
||||
// sort by asset size for assets with same texture types
|
||||
if (entry1.UsableSize > entry2.UsableSize) return 1;
|
||||
if (entry1.UsableSize < entry2.UsableSize) return -1;
|
||||
|
||||
// same size
|
||||
// sort by asset name for assets with same sizes
|
||||
return SortByAssetNameAscending(entry1, entry2);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
static void SortByText(BuildReportTool.SizePart[] assetList, BuildReportTool.AssetList.SortOrder sortOrder, Func<string, string, int> compare)
|
||||
{
|
||||
if (sortOrder == BuildReportTool.AssetList.SortOrder.Descending)
|
||||
{
|
||||
Array.Sort(assetList, delegate(BuildReportTool.SizePart entry1, BuildReportTool.SizePart entry2)
|
||||
{
|
||||
int sortTextureTypeResult = compare(entry1.GetTextAuxData(), entry2.GetTextAuxData());
|
||||
if (sortTextureTypeResult != 0)
|
||||
{
|
||||
return sortTextureTypeResult;
|
||||
}
|
||||
|
||||
// same texture type
|
||||
// sort by asset size for assets with same texture types
|
||||
if (entry1.UsableSize > entry2.UsableSize) return -1;
|
||||
if (entry1.UsableSize < entry2.UsableSize) return 1;
|
||||
|
||||
// same size
|
||||
// sort by asset name for assets with same sizes
|
||||
return SortByAssetNameDescending(entry1, entry2);
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
Array.Sort(assetList, delegate(BuildReportTool.SizePart entry1, BuildReportTool.SizePart entry2)
|
||||
{
|
||||
int sortTextureTypeResult = compare(entry2.GetTextAuxData(), entry1.GetTextAuxData());
|
||||
if (sortTextureTypeResult != 0)
|
||||
{
|
||||
return sortTextureTypeResult;
|
||||
}
|
||||
|
||||
// same texture type
|
||||
// sort by asset size for assets with same texture types
|
||||
if (entry1.UsableSize > entry2.UsableSize) return 1;
|
||||
if (entry1.UsableSize < entry2.UsableSize) return -1;
|
||||
|
||||
// same size
|
||||
// sort by asset name for assets with same sizes
|
||||
return SortByAssetNameAscending(entry1, entry2);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// =============================================================================================================
|
||||
|
||||
static void SortTextureData(BuildReportTool.SizePart[] assetList, BuildReportTool.TextureData textureData, BuildReportTool.AssetList.SortOrder sortOrder, Func<BuildReportTool.TextureData.Entry, bool> func)
|
||||
{
|
||||
var textureEntries = textureData.GetTextureData();
|
||||
|
||||
for (int n = 0; n < assetList.Length; ++n)
|
||||
{
|
||||
int boolValue = 0;
|
||||
if (textureEntries.ContainsKey(assetList[n].Name))
|
||||
{
|
||||
boolValue = func(textureEntries[assetList[n].Name]) ? 1 : 0;
|
||||
}
|
||||
|
||||
assetList[n].SetIntAuxData(boolValue);
|
||||
}
|
||||
|
||||
SortByInt(assetList, sortOrder);
|
||||
}
|
||||
|
||||
static void SortTextureData(BuildReportTool.SizePart[] assetList, BuildReportTool.TextureData textureData, BuildReportTool.AssetList.SortOrder sortOrder, Func<BuildReportTool.TextureData.Entry, string> func)
|
||||
{
|
||||
var textureEntries = textureData.GetTextureData();
|
||||
|
||||
for (int n = 0; n < assetList.Length; ++n)
|
||||
{
|
||||
string textData = null;
|
||||
if (textureEntries.ContainsKey(assetList[n].Name))
|
||||
{
|
||||
textData = func(textureEntries[assetList[n].Name]);
|
||||
}
|
||||
|
||||
assetList[n].SetTextAuxData(textData);
|
||||
}
|
||||
|
||||
SortByText(assetList, sortOrder);
|
||||
}
|
||||
|
||||
static void SortTextureData(BuildReportTool.SizePart[] assetList, BuildReportTool.TextureData textureData, BuildReportTool.AssetList.SortOrder sortOrder, Func<BuildReportTool.TextureData.Entry, float> func)
|
||||
{
|
||||
var textureEntries = textureData.GetTextureData();
|
||||
|
||||
for (int n = 0; n < assetList.Length; ++n)
|
||||
{
|
||||
float floatValue = 0;
|
||||
if (textureEntries.ContainsKey(assetList[n].Name))
|
||||
{
|
||||
floatValue = func(textureEntries[assetList[n].Name]);
|
||||
}
|
||||
|
||||
assetList[n].SetFloatAuxData(floatValue);
|
||||
}
|
||||
|
||||
SortByFloat(assetList, sortOrder);
|
||||
}
|
||||
|
||||
static void SortTextureData(BuildReportTool.SizePart[] assetList, BuildReportTool.TextureData textureData, BuildReportTool.AssetList.SortOrder sortOrder, Func<BuildReportTool.TextureData.Entry, int> func)
|
||||
{
|
||||
var textureEntries = textureData.GetTextureData();
|
||||
|
||||
for (int n = 0; n < assetList.Length; ++n)
|
||||
{
|
||||
int intValue = 0;
|
||||
if (textureEntries.ContainsKey(assetList[n].Name))
|
||||
{
|
||||
intValue = func(textureEntries[assetList[n].Name]);
|
||||
}
|
||||
|
||||
assetList[n].SetIntAuxData(intValue);
|
||||
}
|
||||
|
||||
SortByInt(assetList, sortOrder);
|
||||
}
|
||||
|
||||
// NPotScale sort is special: we want the "None (Not Power of 2)" values to go at top, ignoring alphabetical order for that special value
|
||||
static void SortNPotScale(BuildReportTool.SizePart[] assetList, BuildReportTool.TextureData textureData, BuildReportTool.AssetList.SortOrder sortOrder)
|
||||
{
|
||||
var textureEntries = textureData.GetTextureData();
|
||||
|
||||
for (int n = 0; n < assetList.Length; ++n)
|
||||
{
|
||||
string textData = null;
|
||||
if (textureEntries.ContainsKey(assetList[n].Name))
|
||||
{
|
||||
textData = textureEntries[assetList[n].Name].NPotScale;
|
||||
}
|
||||
|
||||
assetList[n].SetTextAuxData(textData);
|
||||
}
|
||||
|
||||
if (sortOrder == BuildReportTool.AssetList.SortOrder.Descending)
|
||||
{
|
||||
Array.Sort(assetList, delegate(BuildReportTool.SizePart entry1, BuildReportTool.SizePart entry2)
|
||||
{
|
||||
string nPotScale1 = entry1.GetTextAuxData();
|
||||
string nPotScale2 = entry2.GetTextAuxData();
|
||||
|
||||
// put non-power-of-2 at top
|
||||
bool nPotScale1IsNoneNot = nPotScale1 == BuildReportTool.TextureData.NPOT_SCALE_NONE_NOT_POT;
|
||||
bool nPotScale2IsNoneNot = nPotScale2 == BuildReportTool.TextureData.NPOT_SCALE_NONE_NOT_POT;
|
||||
if (nPotScale1IsNoneNot && !nPotScale2IsNoneNot)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
if (!nPotScale1IsNoneNot && nPotScale2IsNoneNot)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
// at this point, entry1 and entry 2 are not non-power-of-2 (or both of them are), so compare them as usual
|
||||
int sortTextureTypeResult = string.Compare(nPotScale1, nPotScale2, StringComparison.OrdinalIgnoreCase);
|
||||
if (sortTextureTypeResult != 0)
|
||||
{
|
||||
return sortTextureTypeResult;
|
||||
}
|
||||
|
||||
// same nPotScale type
|
||||
// sort by asset size for assets with same nPotScale types
|
||||
if (entry1.UsableSize > entry2.UsableSize) return -1;
|
||||
if (entry1.UsableSize < entry2.UsableSize) return 1;
|
||||
|
||||
// same size
|
||||
// sort by asset name for assets with same sizes
|
||||
return SortByAssetNameDescending(entry1, entry2);
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
Array.Sort(assetList, delegate(BuildReportTool.SizePart entry1, BuildReportTool.SizePart entry2)
|
||||
{
|
||||
string nPotScale1 = entry1.GetTextAuxData();
|
||||
string nPotScale2 = entry2.GetTextAuxData();
|
||||
|
||||
// put non-power-of-2 at bottom
|
||||
bool nPotScale1IsNoneNot = nPotScale1 == BuildReportTool.TextureData.NPOT_SCALE_NONE_NOT_POT;
|
||||
bool nPotScale2IsNoneNot = nPotScale2 == BuildReportTool.TextureData.NPOT_SCALE_NONE_NOT_POT;
|
||||
if (nPotScale1IsNoneNot && !nPotScale2IsNoneNot)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
if (!nPotScale1IsNoneNot && nPotScale2IsNoneNot)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
// at this point, entry1 and entry 2 are not non-power-of-2 (or both of them are), so compare them as usual
|
||||
int sortTextureTypeResult = string.Compare(nPotScale2, nPotScale1, StringComparison.OrdinalIgnoreCase);
|
||||
if (sortTextureTypeResult != 0)
|
||||
{
|
||||
return sortTextureTypeResult;
|
||||
}
|
||||
|
||||
// same nPotScale type
|
||||
// sort by asset size for assets with same nPotScale types
|
||||
if (entry1.UsableSize > entry2.UsableSize) return 1;
|
||||
if (entry1.UsableSize < entry2.UsableSize) return -1;
|
||||
|
||||
// same size
|
||||
// sort by asset name for assets with same sizes
|
||||
return SortByAssetNameAscending(entry1, entry2);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ce767224a570c654b8fa057ab56f9655
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,67 @@
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System.IO;
|
||||
|
||||
public static class BRT_LibCacheUtil
|
||||
{
|
||||
// assetPath is expected to start with "Assets/"
|
||||
//
|
||||
// since this function calls AssetDatabase.AssetPathToGUID(),
|
||||
// it can only be called from the Unity main thread
|
||||
//
|
||||
public static long GetImportedFileSize(string assetPath)
|
||||
{
|
||||
long result = -1;
|
||||
|
||||
assetPath = BuildReportTool.Util.MyHtmlDecode(assetPath);
|
||||
|
||||
// files in "StreamingAssets" folder do not get imported
|
||||
// in the 1st place, so skip them
|
||||
if (BuildReportTool.Util.IsFileStreamingAsset(assetPath))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
// files like Thumbs.db or .DS_Store files do not get imported
|
||||
if (BuildReportTool.Util.IsUselessFile(assetPath))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Unix-style hidden files do not get imported
|
||||
if (BuildReportTool.Util.IsFileAUnixHiddenFile(assetPath))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(assetPath))
|
||||
{
|
||||
string guid = AssetDatabase.AssetPathToGUID(assetPath);
|
||||
if (guid.Length < 2)
|
||||
{
|
||||
//Debug.Log(assetPath + " has no guid? value is \"" + guid + "\"");
|
||||
return -1;
|
||||
}
|
||||
|
||||
string assetImportedPath =
|
||||
Path.GetFullPath(Application.dataPath + "../../Library/cache/" + guid.Substring(0, 2) + "/" + guid);
|
||||
|
||||
if (File.Exists(assetImportedPath))
|
||||
{
|
||||
result = BuildReportTool.Util.GetFileSizeInBytes(assetImportedPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
//Debug.Log(assetPath + " not found: " + assetImportedPath);
|
||||
assetImportedPath =
|
||||
Path.GetFullPath(Application.dataPath + "../../Library/metadata/" + guid.Substring(0, 2) + "/" + guid);
|
||||
if (File.Exists(assetImportedPath))
|
||||
{
|
||||
result = BuildReportTool.Util.GetFileSizeInBytes(assetImportedPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4e196d8f60acab14686d24e69b820790
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
2571
Assets/Plugins/BuildReport/Scripts/Editor/Utility/BRT_Util.cs
Normal file
2571
Assets/Plugins/BuildReport/Scripts/Editor/Utility/BRT_Util.cs
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f528fefa626a0440daf1137d5a319f28
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
@@ -0,0 +1,92 @@
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace DldUtil
|
||||
{
|
||||
// from http://arstechnica.com/civis/viewtopic.php?p=22839293&sid=e2bcb348ac8b58c9016e6a0a6442ba1b#p22839293
|
||||
public class BackwardReader
|
||||
{
|
||||
readonly FileStream fs;
|
||||
|
||||
public BackwardReader(string path)
|
||||
{
|
||||
fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
|
||||
}
|
||||
|
||||
public void JumpToEnd(long lineNumber)
|
||||
{
|
||||
fs.Seek(0, SeekOrigin.End);
|
||||
}
|
||||
|
||||
public void JumpToLine(long lineNumber)
|
||||
{
|
||||
fs.Seek(lineNumber, SeekOrigin.Begin);
|
||||
}
|
||||
|
||||
public string ReadLine()
|
||||
{
|
||||
var text = new byte[1];
|
||||
long position = 0;
|
||||
|
||||
fs.Seek(0, SeekOrigin.Current);
|
||||
position = fs.Position;
|
||||
|
||||
// do we have a trailing \r\n?
|
||||
if (fs.Length > 1)
|
||||
{
|
||||
var vagnretur = new byte[2];
|
||||
|
||||
fs.Seek(-2, SeekOrigin.Current);
|
||||
fs.Read(vagnretur, 0, 2);
|
||||
|
||||
if (Encoding.ASCII.GetString(vagnretur).Equals("\r\n"))
|
||||
{
|
||||
// move it back
|
||||
fs.Seek(-2, SeekOrigin.Current);
|
||||
position = fs.Position;
|
||||
}
|
||||
}
|
||||
|
||||
while (fs.Position > 0)
|
||||
{
|
||||
text.Initialize();
|
||||
|
||||
// read one char
|
||||
fs.Read(text, 0, 1);
|
||||
var asciiText = Encoding.ASCII.GetString(text);
|
||||
|
||||
// move back to the character before
|
||||
fs.Seek(-2, SeekOrigin.Current);
|
||||
|
||||
if (asciiText.Equals("\n"))
|
||||
{
|
||||
fs.Read(text, 0, 1);
|
||||
|
||||
asciiText = Encoding.ASCII.GetString(text);
|
||||
if (asciiText.Equals("\r"))
|
||||
{
|
||||
fs.Seek(1, SeekOrigin.Current);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var count = int.Parse((position - fs.Position).ToString());
|
||||
var line = new byte[count];
|
||||
fs.Read(line, 0, count);
|
||||
fs.Seek(-count, SeekOrigin.Current);
|
||||
|
||||
return Encoding.ASCII.GetString(line);
|
||||
}
|
||||
|
||||
public bool SOF
|
||||
{
|
||||
get { return fs.Position == 0; }
|
||||
}
|
||||
|
||||
public void Close()
|
||||
{
|
||||
fs.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2e985eb9b8631424b9e93f8901cdefab
|
||||
timeCreated: 1456670746
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,292 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
namespace DldUtil
|
||||
{
|
||||
public static class BigFileReader
|
||||
{
|
||||
public static bool FileHasText(string path, params string[] seekText)
|
||||
{
|
||||
if (!File.Exists(path))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
FileStream fs = File.Open(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
|
||||
BufferedStream bs = new BufferedStream(fs);
|
||||
StreamReader sr = new StreamReader(bs);
|
||||
|
||||
while (true)
|
||||
{
|
||||
var line = sr.ReadLine();
|
||||
|
||||
if (line == null)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
for (var seekTextIdx = 0; seekTextIdx < seekText.Length; ++seekTextIdx)
|
||||
{
|
||||
if (line.IndexOf(seekText[seekTextIdx], StringComparison.Ordinal) >= 0)
|
||||
{
|
||||
sr.Close();
|
||||
bs.Close();
|
||||
fs.Close();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sr.Close();
|
||||
bs.Close();
|
||||
fs.Close();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static string SeekText(string path, params string[] seekText)
|
||||
{
|
||||
FileStream fs = File.Open(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
|
||||
BufferedStream bs = new BufferedStream(fs);
|
||||
StreamReader sr = new StreamReader(bs);
|
||||
|
||||
//long currentLine = 0;
|
||||
while (true)
|
||||
{
|
||||
//++currentLine;
|
||||
var line = sr.ReadLine();
|
||||
//Debug.LogFormat("seeking... line number {0}: {1}", currentLine, line);
|
||||
|
||||
// reached end of file?
|
||||
if (line == null)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
for (var seekTextIdx = 0; seekTextIdx < seekText.Length; ++seekTextIdx)
|
||||
{
|
||||
if (line.IndexOf(seekText[seekTextIdx], StringComparison.Ordinal) >= 0)
|
||||
{
|
||||
return line;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
public struct FoundText
|
||||
{
|
||||
public long LineNumber;
|
||||
public string Text;
|
||||
}
|
||||
|
||||
public static List<FoundText> SeekAllText(string path, params string[] seekText)
|
||||
{
|
||||
if (!File.Exists(path))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
FileStream fs = File.Open(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
|
||||
BufferedStream bs = new BufferedStream(fs);
|
||||
StreamReader sr = new StreamReader(bs);
|
||||
|
||||
List<FoundText> returnValue = new List<FoundText>();
|
||||
|
||||
long currentLine = 0;
|
||||
while (true)
|
||||
{
|
||||
++currentLine;
|
||||
var line = sr.ReadLine();
|
||||
//Debug.LogFormat("seeking... line number {0}: {1}", currentLine, line);
|
||||
|
||||
// reached end of file?
|
||||
if (line == null)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
for (var seekTextIdx = 0; seekTextIdx < seekText.Length; ++seekTextIdx)
|
||||
{
|
||||
if (line.IndexOf(seekText[seekTextIdx], StringComparison.Ordinal) >= 0)
|
||||
{
|
||||
FoundText newFoundText;
|
||||
newFoundText.LineNumber = currentLine;
|
||||
newFoundText.Text = line;
|
||||
returnValue.Add(newFoundText);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
public static IEnumerable<string> ReadFile(string path, params string[] seekText)
|
||||
{
|
||||
return ReadFile(path, true, seekText);
|
||||
}
|
||||
|
||||
public static IEnumerable<string> ReadFile(string path, bool startAfterSeekedText, params string[] seekText)
|
||||
{
|
||||
if (!File.Exists(path))
|
||||
{
|
||||
yield break;
|
||||
}
|
||||
|
||||
var fs = File.Open(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
|
||||
var bs = new BufferedStream(fs);
|
||||
var sr = new StreamReader(bs);
|
||||
|
||||
string line;
|
||||
|
||||
bool seekTextRequested = (seekText != null) && (seekText.Length > 0) && !string.IsNullOrEmpty(seekText[0]);
|
||||
|
||||
|
||||
long seekTextFoundAtLine = -1;
|
||||
|
||||
|
||||
if (seekTextRequested)
|
||||
{
|
||||
long currentLine = 0;
|
||||
while (true)
|
||||
{
|
||||
++currentLine;
|
||||
line = sr.ReadLine();
|
||||
//Debug.LogFormat("seeking... line number {0}: {1}", currentLine, line);
|
||||
|
||||
// reached end of file?
|
||||
if (line == null)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
var atLeastOneSeekTextFound = false;
|
||||
for (var seekTextIdx = 0; seekTextIdx < seekText.Length; ++seekTextIdx)
|
||||
{
|
||||
if (line.IndexOf(seekText[seekTextIdx], StringComparison.Ordinal) >= 0)
|
||||
{
|
||||
atLeastOneSeekTextFound = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// if seekText not found yet, continue search
|
||||
if (!atLeastOneSeekTextFound)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
seekTextFoundAtLine = currentLine;
|
||||
|
||||
//Debug.Log("seeking: " + line);
|
||||
//Debug.LogFormat("seekText found at line number {0}: {1}", currentLine, line);
|
||||
}
|
||||
//Debug.Log("done seeking");
|
||||
|
||||
if (seekTextFoundAtLine != -1)
|
||||
{
|
||||
fs.Seek(0, SeekOrigin.Begin);
|
||||
|
||||
currentLine = 0;
|
||||
while (true)
|
||||
{
|
||||
++currentLine;
|
||||
line = sr.ReadLine();
|
||||
|
||||
if (line == null)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if (startAfterSeekedText && currentLine <= seekTextFoundAtLine)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!startAfterSeekedText && currentLine < seekTextFoundAtLine)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//Debug.Log("seeked: " + line);
|
||||
|
||||
yield return line;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
line = sr.ReadLine();
|
||||
|
||||
if (line == null)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
yield return line;
|
||||
}
|
||||
}
|
||||
|
||||
sr.Close();
|
||||
bs.Close();
|
||||
fs.Close();
|
||||
}
|
||||
|
||||
|
||||
public static IEnumerable<string> ReadFile(string path)
|
||||
{
|
||||
var fs = File.Open(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
|
||||
var bs = new BufferedStream(fs);
|
||||
var sr = new StreamReader(bs);
|
||||
|
||||
while (true)
|
||||
{
|
||||
var line = sr.ReadLine();
|
||||
|
||||
if (line == null)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
yield return line;
|
||||
}
|
||||
|
||||
sr.Close();
|
||||
bs.Close();
|
||||
fs.Close();
|
||||
}
|
||||
|
||||
public static IEnumerable<FoundText> ReadFileWithLine(string path)
|
||||
{
|
||||
var fs = File.Open(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
|
||||
var bs = new BufferedStream(fs);
|
||||
var sr = new StreamReader(bs);
|
||||
|
||||
long currentLineNumber = 0;
|
||||
while (true)
|
||||
{
|
||||
++currentLineNumber;
|
||||
var line = sr.ReadLine();
|
||||
|
||||
if (line == null)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
FoundText text;
|
||||
text.Text = line;
|
||||
text.LineNumber = currentLineNumber;
|
||||
yield return text;
|
||||
}
|
||||
|
||||
sr.Close();
|
||||
bs.Close();
|
||||
fs.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8542a3803dd50b84ab3795bd8fe6bcf4
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
@@ -0,0 +1,223 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace DldUtil
|
||||
{
|
||||
public static class GetRspDefines
|
||||
{
|
||||
static string SmcsFilePath
|
||||
{
|
||||
get { return Application.dataPath + "/smcs.rsp"; }
|
||||
}
|
||||
|
||||
static string McsFilePath
|
||||
{
|
||||
get { return Application.dataPath + "/mcs.rsp"; }
|
||||
}
|
||||
|
||||
static string UsFilePath
|
||||
{
|
||||
get { return Application.dataPath + "/us.rsp"; }
|
||||
}
|
||||
|
||||
static string BooFilePath
|
||||
{
|
||||
get { return Application.dataPath + "/boo.rsp"; }
|
||||
}
|
||||
|
||||
public struct Entry
|
||||
{
|
||||
public int TimesDefinedInSmcs;
|
||||
public int TimesDefinedInMcs;
|
||||
public int TimesDefinedInUs;
|
||||
public int TimesDefinedInBoo;
|
||||
public int TimesDefinedInBuiltIn;
|
||||
}
|
||||
|
||||
// Unity-made defines are in EditorUserBuildSettings.activeScriptCompilationDefines
|
||||
static bool IsDefineAlreadyInUnity(string defineName)
|
||||
{
|
||||
string[] builtInDefines = EditorUserBuildSettings.activeScriptCompilationDefines;
|
||||
|
||||
for (int n = 0, len = builtInDefines.Length; n < len; n++)
|
||||
{
|
||||
if (builtInDefines[n] == defineName)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// ========================================================================================
|
||||
|
||||
static void IncrementTimesDefinedInBuiltIn(Dictionary<string, Entry> table, string define)
|
||||
{
|
||||
if (!table.ContainsKey(define))
|
||||
{
|
||||
table[define] = new Entry();
|
||||
}
|
||||
|
||||
Entry currentDef = table[define];
|
||||
currentDef.TimesDefinedInBuiltIn++;
|
||||
|
||||
// assign it back to store it
|
||||
table[define] = currentDef;
|
||||
}
|
||||
|
||||
static void IncrementTimesDefinedInSmcs(Dictionary<string, Entry> table, string define)
|
||||
{
|
||||
if (!table.ContainsKey(define))
|
||||
{
|
||||
table[define] = new Entry();
|
||||
}
|
||||
|
||||
Entry currentDef = table[define];
|
||||
currentDef.TimesDefinedInSmcs++;
|
||||
|
||||
// assign it back to store it
|
||||
table[define] = currentDef;
|
||||
}
|
||||
|
||||
static void IncrementTimesDefinedInMcs(Dictionary<string, Entry> table, string define)
|
||||
{
|
||||
if (!table.ContainsKey(define))
|
||||
{
|
||||
table[define] = new Entry();
|
||||
}
|
||||
|
||||
Entry currentDef = table[define];
|
||||
currentDef.TimesDefinedInMcs++;
|
||||
|
||||
// assign it back to store it
|
||||
table[define] = currentDef;
|
||||
}
|
||||
|
||||
static void IncrementTimesDefinedInUs(Dictionary<string, Entry> table, string define)
|
||||
{
|
||||
if (!table.ContainsKey(define))
|
||||
{
|
||||
table[define] = new Entry();
|
||||
}
|
||||
|
||||
Entry currentDef = table[define];
|
||||
currentDef.TimesDefinedInUs++;
|
||||
|
||||
// assign it back to store it
|
||||
table[define] = currentDef;
|
||||
}
|
||||
|
||||
static void IncrementTimesDefinedInBoo(Dictionary<string, Entry> table, string define)
|
||||
{
|
||||
if (!table.ContainsKey(define))
|
||||
{
|
||||
table[define] = new Entry();
|
||||
}
|
||||
|
||||
Entry currentDef = table[define];
|
||||
currentDef.TimesDefinedInBoo++;
|
||||
|
||||
// assign it back to store it
|
||||
table[define] = currentDef;
|
||||
}
|
||||
|
||||
// ========================================================================================
|
||||
|
||||
public static Dictionary<string, Entry> GetDefines()
|
||||
{
|
||||
Dictionary<string, Entry> result = new Dictionary<string, Entry>();
|
||||
|
||||
// ---------------------------------------------------------
|
||||
|
||||
string[] definesInSmcs = GetDefinesInsideFile(SmcsFilePath);
|
||||
|
||||
if (definesInSmcs != null && definesInSmcs.Length > 0)
|
||||
{
|
||||
for (int n = 0, len = definesInSmcs.Length; n < len; n++)
|
||||
{
|
||||
IncrementTimesDefinedInSmcs(result, definesInSmcs[n]);
|
||||
if (IsDefineAlreadyInUnity(definesInSmcs[n]))
|
||||
{
|
||||
IncrementTimesDefinedInBuiltIn(result, definesInSmcs[n]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------
|
||||
|
||||
string[] definesInMcs = GetDefinesInsideFile(McsFilePath);
|
||||
|
||||
if (definesInMcs != null && definesInMcs.Length > 0)
|
||||
{
|
||||
for (int n = 0, len = definesInMcs.Length; n < len; n++)
|
||||
{
|
||||
IncrementTimesDefinedInMcs(result, definesInMcs[n]);
|
||||
if (IsDefineAlreadyInUnity(definesInMcs[n]))
|
||||
{
|
||||
IncrementTimesDefinedInBuiltIn(result, definesInMcs[n]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------
|
||||
|
||||
string[] definesInUs = GetDefinesInsideFile(UsFilePath);
|
||||
|
||||
if (definesInUs != null && definesInUs.Length > 0)
|
||||
{
|
||||
for (int n = 0, len = definesInUs.Length; n < len; n++)
|
||||
{
|
||||
IncrementTimesDefinedInUs(result, definesInUs[n]);
|
||||
if (IsDefineAlreadyInUnity(definesInUs[n]))
|
||||
{
|
||||
IncrementTimesDefinedInBuiltIn(result, definesInUs[n]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------
|
||||
|
||||
string[] definesInBoo = GetDefinesInsideFile(BooFilePath);
|
||||
|
||||
if (definesInBoo != null && definesInBoo.Length > 0)
|
||||
{
|
||||
for (int n = 0, len = definesInBoo.Length; n < len; n++)
|
||||
{
|
||||
IncrementTimesDefinedInBoo(result, definesInBoo[n]);
|
||||
if (IsDefineAlreadyInUnity(definesInBoo[n]))
|
||||
{
|
||||
IncrementTimesDefinedInBuiltIn(result, definesInBoo[n]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static string[] GetDefinesInsideFile(string filePath)
|
||||
{
|
||||
if (!File.Exists(filePath))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
string rawContents = File.ReadAllText(filePath);
|
||||
if (!rawContents.StartsWith("-define:"))
|
||||
{
|
||||
// malformed .rsp file
|
||||
return null;
|
||||
}
|
||||
|
||||
// remove "-define:"
|
||||
string allDefines = rawContents.Substring(8);
|
||||
//Debug.Log(allDefines);
|
||||
|
||||
return allDefines.Split(';');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1e536a29403c28f479da249218b27ee2
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
@@ -0,0 +1,124 @@
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
namespace DldUtil
|
||||
{
|
||||
public static class TraverseDirectory
|
||||
{
|
||||
struct TraversalStack
|
||||
{
|
||||
public string TopFolder;
|
||||
public long ChildIdxToGoOnReturn; // idx to go to when resuming from lower/inner level of depth
|
||||
}
|
||||
|
||||
const long OUTER_LOOP_LIMIT = 1000000; // 1 million
|
||||
const long FILE_LIMIT = 4000000000; // 4 billion
|
||||
|
||||
public static IEnumerable<string> Do(string path)
|
||||
{
|
||||
Stack<TraversalStack> traversal = new Stack<TraversalStack>(5);
|
||||
|
||||
TraversalStack initial;
|
||||
initial.TopFolder = path;
|
||||
initial.ChildIdxToGoOnReturn = 0;
|
||||
|
||||
traversal.Push(initial);
|
||||
|
||||
|
||||
// guard against infinite loop
|
||||
long infiniteCounterStack = 0;
|
||||
long infiniteCounterFile = 0;
|
||||
|
||||
TraversalStack currentStack;
|
||||
|
||||
|
||||
while (traversal.Count > 0)
|
||||
{
|
||||
++infiniteCounterStack;
|
||||
if (infiniteCounterStack > OUTER_LOOP_LIMIT)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
currentStack = traversal.Peek();
|
||||
//Debug.Log("in " + currentStack.TopFolder);
|
||||
|
||||
bool toGoDeeper = false;
|
||||
|
||||
string[] allInCurrentFolder = Directory.GetFileSystemEntries(currentStack.TopFolder);
|
||||
|
||||
infiniteCounterFile = 0;
|
||||
for (long n = currentStack.ChildIdxToGoOnReturn, len = allInCurrentFolder.Length; n < len; ++n)
|
||||
{
|
||||
++infiniteCounterFile;
|
||||
if (infiniteCounterFile > FILE_LIMIT)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
//Debug.Log("for loop: [" + n + "] " + allInCurrentFolder[n]);
|
||||
|
||||
if (File.Exists(allInCurrentFolder[n]) && !allInCurrentFolder[n].EndsWith(".meta"))
|
||||
{
|
||||
var returnValue = allInCurrentFolder[n].Replace("\\", "/");
|
||||
returnValue = returnValue.Replace("&", "&");
|
||||
|
||||
yield return returnValue;
|
||||
}
|
||||
else if (Directory.Exists(allInCurrentFolder[n]))
|
||||
{
|
||||
//Debug.Log("is folder: " + allInCurrentFolder[n]);
|
||||
|
||||
// update current stack: change its idx to return to
|
||||
|
||||
currentStack.ChildIdxToGoOnReturn = n + 1;
|
||||
traversal.Pop();
|
||||
traversal.Push(currentStack);
|
||||
|
||||
|
||||
// add new stack so we go inside this folder
|
||||
|
||||
TraversalStack deeper;
|
||||
deeper.TopFolder = allInCurrentFolder[n];
|
||||
deeper.ChildIdxToGoOnReturn = 0;
|
||||
|
||||
traversal.Push(deeper);
|
||||
|
||||
//Debug.Log("pushed " + allInCurrentFolder[n]);
|
||||
|
||||
toGoDeeper = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// if completely finished that for loop,
|
||||
// then we're done with current stack. remove it.
|
||||
if (!toGoDeeper)
|
||||
{
|
||||
//Debug.Log("popped " + currentStack.TopFolder);
|
||||
traversal.Pop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#if UNITY_EDITOR
|
||||
//[MenuItem("Window/Test traverse folder")]
|
||||
public static void TestA()
|
||||
{
|
||||
//string folder = "C:/Users/Ferdi/Projects/_AssetStoreProducts/BuildReportTool/BuildReportToolU353/BuildReportUnityProject/Assets/BuildReport/Scripts";
|
||||
string folder = Application.dataPath;
|
||||
|
||||
Debug.Log("traverse at: " + folder);
|
||||
foreach (string file in Do(folder))
|
||||
{
|
||||
if (BuildReportTool.Util.IsFileOfType(file, ".prefab"))
|
||||
{
|
||||
Debug.Log("traverse stack: " + Path.GetFileName(file));
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 34de8006dd00e8540895016e2be2606f
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
@@ -0,0 +1,171 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace DldUtil
|
||||
{
|
||||
public static class UnityVersion
|
||||
{
|
||||
public static void GetUnityVersionNumbers(string unityVersionString, out int major, out int minor, out int patch)
|
||||
{
|
||||
var splits = unityVersionString.Split(new[] {"Unity", ".", "a", "b", "rc", "f"},
|
||||
StringSplitOptions.RemoveEmptyEntries);
|
||||
|
||||
major = -1;
|
||||
minor = -1;
|
||||
patch = -1;
|
||||
|
||||
if (splits.Length >= 1)
|
||||
{
|
||||
int.TryParse(splits[0], out major);
|
||||
}
|
||||
|
||||
if (splits.Length >= 2)
|
||||
{
|
||||
int.TryParse(splits[1], out minor);
|
||||
}
|
||||
|
||||
if (splits.Length >= 3)
|
||||
{
|
||||
int.TryParse(splits[2], out patch);
|
||||
}
|
||||
}
|
||||
|
||||
public static void GetUnityVersionNumbers(out int major, out int minor, out int patch)
|
||||
{
|
||||
GetUnityVersionNumbers(Application.unityVersion, out major, out minor, out patch);
|
||||
|
||||
//Debug.LogFormat("major: {0}, minor: {1}, patch: {2}", major, minor, patch);
|
||||
}
|
||||
|
||||
public static bool IsUnityVersionAtLeast(int majorAtLeast, int minorAtLeast, int patchAtLeast)
|
||||
{
|
||||
int unityMajor;
|
||||
int unityMinor;
|
||||
int unityPatch;
|
||||
|
||||
GetUnityVersionNumbers(out unityMajor, out unityMinor, out unityPatch);
|
||||
|
||||
if (unityMajor > majorAtLeast)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (unityMajor == majorAtLeast)
|
||||
{
|
||||
if (unityMinor > minorAtLeast)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (unityMinor == minorAtLeast)
|
||||
{
|
||||
if (unityPatch >= patchAtLeast)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool IsUnityVersionAtMost(int majorAtMost, int minorAtMost, int patchAtMost)
|
||||
{
|
||||
int unityMajor;
|
||||
int unityMinor;
|
||||
int unityPatch;
|
||||
|
||||
GetUnityVersionNumbers(out unityMajor, out unityMinor, out unityPatch);
|
||||
|
||||
if (unityMajor < majorAtMost)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (unityMajor == majorAtMost)
|
||||
{
|
||||
if (unityMinor < minorAtMost)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (unityMinor == minorAtMost)
|
||||
{
|
||||
if (unityPatch <= patchAtMost)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public static bool IsUnityVersionAtLeast(string unityVersionString, int majorAtLeast, int minorAtLeast,
|
||||
int patchAtLeast)
|
||||
{
|
||||
int unityMajor;
|
||||
int unityMinor;
|
||||
int unityPatch;
|
||||
|
||||
GetUnityVersionNumbers(unityVersionString, out unityMajor, out unityMinor, out unityPatch);
|
||||
|
||||
if (unityMajor > majorAtLeast)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (unityMajor == majorAtLeast)
|
||||
{
|
||||
if (unityMinor > minorAtLeast)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (unityMinor == minorAtLeast)
|
||||
{
|
||||
if (unityPatch >= patchAtLeast)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool IsUnityVersionAtMost(string unityVersionString, int majorAtMost, int minorAtMost,
|
||||
int patchAtMost)
|
||||
{
|
||||
int unityMajor;
|
||||
int unityMinor;
|
||||
int unityPatch;
|
||||
|
||||
GetUnityVersionNumbers(unityVersionString, out unityMajor, out unityMinor, out unityPatch);
|
||||
|
||||
if (unityMajor < majorAtMost)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (unityMajor == majorAtMost)
|
||||
{
|
||||
if (unityMinor < minorAtMost)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (unityMinor == minorAtMost)
|
||||
{
|
||||
if (unityPatch <= patchAtMost)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 12045753a7d86e548bd5e1b4f00ef56b
|
||||
timeCreated: 1456509724
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,230 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
namespace ImageUtility
|
||||
{
|
||||
public struct Dimensions
|
||||
{
|
||||
public int Width;
|
||||
public int Height;
|
||||
|
||||
public static Dimensions ErrorValue
|
||||
{
|
||||
get
|
||||
{
|
||||
Dimensions returnValue;
|
||||
returnValue.Width = 0;
|
||||
returnValue.Height = 0;
|
||||
return returnValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <para>Retrieves width and height of an image, without loading the entire image in memory.</para>
|
||||
///
|
||||
/// <para>Based on https://stackoverflow.com/a/112711/1377948
|
||||
/// (with edits from https://stackoverflow.com/a/60667939/1377948
|
||||
/// for recognizing progressive jpeg and webp).</para>
|
||||
///
|
||||
/// <para>Code will return (-1, -1) as an error value, instead of any exception throwing.</para>
|
||||
/// </summary>
|
||||
public static class Dimension
|
||||
{
|
||||
static readonly Dictionary<byte[], Func<BinaryReader, Dimensions>> ImageFormatDecoders = new Dictionary<byte[], Func<BinaryReader, Dimensions>>()
|
||||
{
|
||||
{ new byte[] { 0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A }, DecodePng },
|
||||
{ new byte[] { 0x47, 0x49, 0x46, 0x38, 0x37, 0x61 }, DecodeGif },
|
||||
{ new byte[] { 0x47, 0x49, 0x46, 0x38, 0x39, 0x61 }, DecodeGif },
|
||||
{ new byte[] { 0x52, 0x49, 0x46, 0x46 }, DecodeWebP },
|
||||
{ new byte[] { 0xFF, 0xD8 }, DecodeJfif },
|
||||
{ new byte[] { 0x42, 0x4D }, DecodeBitmap },
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Currently the longest we have in <see cref="ImageFormatDecoders"/> is the png one, with 8 bytes.
|
||||
/// </summary>
|
||||
const int LONGEST_MAGIC_BYTES = 8;
|
||||
|
||||
static byte[] _magicBytes;
|
||||
|
||||
/// <summary>
|
||||
/// <para>Retrieves width and height of an image, without loading the entire image in memory.</para>
|
||||
/// </summary>
|
||||
/// <param name="path">Full path to the image to get the dimensions of.</param>
|
||||
/// <returns>(width, height) tuple, or (-1, -1) if not found.</returns>
|
||||
public static Dimensions Get(string path)
|
||||
{
|
||||
using (var binaryReader = new BinaryReader(File.OpenRead(path)))
|
||||
{
|
||||
return Get(binaryReader);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <para>Retrieves width and height of an image opened in a BinaryReader.
|
||||
/// It will only read through the BinaryReader as least as it possibly
|
||||
/// can to get to the width and height.</para>
|
||||
/// </summary>
|
||||
/// <param name="binaryReader">A BinaryReader with the image file opened in it.</param>
|
||||
/// <returns>(width, height) tuple, or (-1, -1) if not found.</returns>
|
||||
public static Dimensions Get(BinaryReader binaryReader)
|
||||
{
|
||||
if (_magicBytes == null)
|
||||
{
|
||||
_magicBytes = new byte[LONGEST_MAGIC_BYTES];
|
||||
}
|
||||
else
|
||||
{
|
||||
// reset the byte array checker to 0 value
|
||||
for (int i = 0; i < LONGEST_MAGIC_BYTES; i += 1)
|
||||
{
|
||||
_magicBytes[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Detect the image type not using the file type,
|
||||
// but via the bytes it has at the start of the file.
|
||||
//
|
||||
// We read up to n number of bytes at the start of the file (where n is LONGEST_MAGIC_BYTES),
|
||||
// and each time we've appended to the _magicBytes we're reading,
|
||||
// check if what we have so far matches any of the image types we know.
|
||||
for (int i = 0; i < LONGEST_MAGIC_BYTES; i += 1)
|
||||
{
|
||||
_magicBytes[i] = binaryReader.ReadByte();
|
||||
|
||||
foreach (var kvPair in ImageFormatDecoders)
|
||||
{
|
||||
if (_magicBytes.StartsWith(kvPair.Key))
|
||||
{
|
||||
// The bytes have been recognized as one of our known image types,
|
||||
// now we use the Decode method assigned for that image type.
|
||||
return kvPair.Value(binaryReader);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Dimensions.ErrorValue;
|
||||
}
|
||||
|
||||
// =================================================================================
|
||||
|
||||
static bool StartsWith(this byte[] thisBytes, byte[] thatBytes)
|
||||
{
|
||||
for (int i = 0; i < thatBytes.Length; i += 1)
|
||||
{
|
||||
if (thisBytes[i] != thatBytes[i])
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
const int SIZE_OF_SHORT = sizeof(short);
|
||||
static readonly byte[] ShortBytes = new byte[SIZE_OF_SHORT];
|
||||
static short ReadLittleEndianInt16(this BinaryReader binaryReader)
|
||||
{
|
||||
for (int i = 0; i < SIZE_OF_SHORT; i += 1)
|
||||
{
|
||||
ShortBytes[SIZE_OF_SHORT - 1 - i] = binaryReader.ReadByte();
|
||||
}
|
||||
|
||||
return BitConverter.ToInt16(ShortBytes, 0);
|
||||
}
|
||||
|
||||
const int SIZE_OF_INT = sizeof(int);
|
||||
static readonly byte[] IntBytes = new byte[SIZE_OF_INT];
|
||||
static int ReadLittleEndianInt32(this BinaryReader binaryReader)
|
||||
{
|
||||
for (int i = 0; i < SIZE_OF_INT; i += 1)
|
||||
{
|
||||
IntBytes[SIZE_OF_INT - 1 - i] = binaryReader.ReadByte();
|
||||
}
|
||||
|
||||
return BitConverter.ToInt32(IntBytes, 0);
|
||||
}
|
||||
|
||||
// =================================================================================
|
||||
|
||||
static Dimensions DecodeBitmap(BinaryReader binaryReader)
|
||||
{
|
||||
binaryReader.ReadBytes(16);
|
||||
Dimensions returnValue;
|
||||
returnValue.Width = binaryReader.ReadInt32();
|
||||
returnValue.Height = binaryReader.ReadInt32();
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
static Dimensions DecodeGif(BinaryReader binaryReader)
|
||||
{
|
||||
Dimensions returnValue;
|
||||
returnValue.Width = binaryReader.ReadInt16();
|
||||
returnValue.Height = binaryReader.ReadInt16();
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
static Dimensions DecodePng(BinaryReader binaryReader)
|
||||
{
|
||||
binaryReader.ReadBytes(8);
|
||||
Dimensions returnValue;
|
||||
returnValue.Width = binaryReader.ReadLittleEndianInt32();
|
||||
returnValue.Height = binaryReader.ReadLittleEndianInt32();
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
static Dimensions DecodeJfif(BinaryReader binaryReader)
|
||||
{
|
||||
while (binaryReader.ReadByte() == 0xFF) // skipp FF
|
||||
{
|
||||
byte marker = binaryReader.ReadByte();
|
||||
short chunkLength = binaryReader.ReadLittleEndianInt16();
|
||||
|
||||
// C2: progressive (from https://stackoverflow.com/a/60667939/1377948)
|
||||
if (marker == 0xC0 || marker == 0xC2)
|
||||
{
|
||||
binaryReader.ReadByte();
|
||||
|
||||
Dimensions returnValue;
|
||||
returnValue.Height = binaryReader.ReadLittleEndianInt16();
|
||||
returnValue.Width = binaryReader.ReadLittleEndianInt16();
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
if (chunkLength < 0)
|
||||
{
|
||||
ushort uChunkLength = (ushort)chunkLength;
|
||||
binaryReader.ReadBytes(uChunkLength - 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
binaryReader.ReadBytes(chunkLength - 2);
|
||||
}
|
||||
}
|
||||
|
||||
return Dimensions.ErrorValue;
|
||||
}
|
||||
|
||||
// (from https://stackoverflow.com/a/60667939/1377948)
|
||||
static Dimensions DecodeWebP(BinaryReader binaryReader)
|
||||
{
|
||||
binaryReader.ReadUInt32(); // Size
|
||||
binaryReader.ReadBytes(15); // WEBP, VP8 + more
|
||||
binaryReader.ReadBytes(3); // SYNC
|
||||
|
||||
Dimensions returnValue;
|
||||
|
||||
// 14 bits (ignore last 2 bits of the 16 bit value) for width
|
||||
returnValue.Width = binaryReader.ReadUInt16() & 0x3FFF;
|
||||
|
||||
// 14 bits (ignore last 2 bits of the 16 bit value) for height
|
||||
returnValue.Height = binaryReader.ReadUInt16() & 0x3FFF;
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
// =================================================================================
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4b0199226a7dee14fa4f0865aee45839
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,76 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace BuildReportTool
|
||||
{
|
||||
[System.Serializable]
|
||||
public class SessionData : IDataFile
|
||||
{
|
||||
public bool ShouldGetBuildReportNow;
|
||||
public bool ShouldSaveGottenBuildReportNow;
|
||||
public string BuildTimeStart;
|
||||
public string BuildTimeDuration;
|
||||
public int LastTargetBuild;
|
||||
|
||||
System.DateTime _savedBuildTimeStart = new System.DateTime(0);
|
||||
public bool HasBuildTime()
|
||||
{
|
||||
return _savedBuildTimeStart.Ticks > 0;
|
||||
}
|
||||
public void SetBuildTimeToNow()
|
||||
{
|
||||
_savedBuildTimeStart = System.DateTime.Now;
|
||||
BuildTimeStart = _savedBuildTimeStart.ToString("u", System.Globalization.CultureInfo.InvariantCulture);
|
||||
}
|
||||
public System.DateTime GetBuildTime()
|
||||
{
|
||||
return _savedBuildTimeStart;
|
||||
}
|
||||
public void ClearBuildTime()
|
||||
{
|
||||
_savedBuildTimeStart = default;
|
||||
}
|
||||
|
||||
public void SaveBuildTimeDuration()
|
||||
{
|
||||
if (_savedBuildTimeStart.Ticks <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var timeSpanBuildStart = new System.TimeSpan(_savedBuildTimeStart.Ticks);
|
||||
var timeSpanNow = new System.TimeSpan(System.DateTime.Now.Ticks);
|
||||
var buildDurationTime = timeSpanNow - timeSpanBuildStart;
|
||||
|
||||
// ----------------------
|
||||
|
||||
BuildTimeDuration = buildDurationTime.ToString();
|
||||
}
|
||||
|
||||
public System.TimeSpan LoadBuildTimeDuration()
|
||||
{
|
||||
return System.TimeSpan.Parse(BuildTimeDuration);
|
||||
}
|
||||
|
||||
public void OnBeforeSave()
|
||||
{
|
||||
}
|
||||
|
||||
public void OnAfterLoad()
|
||||
{
|
||||
_savedBuildTimeStart = !string.IsNullOrEmpty(BuildTimeStart)
|
||||
? System.DateTime.ParseExact(BuildTimeStart, "u", System.Globalization.CultureInfo.InvariantCulture)
|
||||
: default;
|
||||
}
|
||||
|
||||
public void SetSavedPath(string savedPath)
|
||||
{
|
||||
}
|
||||
|
||||
public string SavedPath => null;
|
||||
|
||||
public string GetDefaultFilename()
|
||||
{
|
||||
return $"{BuildReportTool.Util.RemoveSuffix("Assets", Application.dataPath)}Library/BuildReportTool-SessionData.xml";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4f40784f52405934f8f84575a0a89f42
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user