初始化仓库
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
namespace UnityGameFramework.Editor.ResourceTools
|
||||
{
|
||||
/// <summary>
|
||||
/// 对 AssetBundle 应用的压缩算法类型。
|
||||
/// </summary>
|
||||
public enum AssetBundleCompressionType : byte
|
||||
{
|
||||
/// <summary>
|
||||
/// 不使用压缩算法。
|
||||
/// </summary>
|
||||
Uncompressed = 0,
|
||||
|
||||
/// <summary>
|
||||
/// 使用 LZ4 压缩算法。
|
||||
/// </summary>
|
||||
LZ4,
|
||||
|
||||
/// <summary>
|
||||
/// 使用 LZMA 压缩算法。
|
||||
/// </summary>
|
||||
LZMA
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 690743de30449bf46aa333e5117930d1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,138 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityGameFramework.Editor.ResourceTools
|
||||
{
|
||||
/// <summary>
|
||||
/// 生成资源事件处理函数。
|
||||
/// </summary>
|
||||
public interface IBuildEventHandler
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取当某个平台生成失败时,是否继续生成下一个平台。
|
||||
/// </summary>
|
||||
bool ContinueOnFailure
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 所有平台生成开始前的预处理事件。
|
||||
/// </summary>
|
||||
/// <param name="productName">产品名称。</param>
|
||||
/// <param name="companyName">公司名称。</param>
|
||||
/// <param name="gameIdentifier">游戏识别号。</param>
|
||||
/// <param name="gameFrameworkVersion">游戏框架版本。</param>
|
||||
/// <param name="unityVersion">Unity 版本。</param>
|
||||
/// <param name="applicableGameVersion">适用游戏版本。</param>
|
||||
/// <param name="internalResourceVersion">内部资源版本。</param>
|
||||
/// <param name="platforms">生成的目标平台。</param>
|
||||
/// <param name="assetBundleCompression">AssetBundle 压缩类型。</param>
|
||||
/// <param name="compressionHelperTypeName">压缩解压缩辅助器类型名称。</param>
|
||||
/// <param name="additionalCompressionSelected">是否进行再压缩以降低传输开销。</param>
|
||||
/// <param name="forceRebuildAssetBundleSelected">是否强制重新构建 AssetBundle。</param>
|
||||
/// <param name="buildEventHandlerTypeName">生成资源事件处理函数名称。</param>
|
||||
/// <param name="outputDirectory">生成目录。</param>
|
||||
/// <param name="buildAssetBundleOptions">AssetBundle 生成选项。</param>
|
||||
/// <param name="workingPath">生成时的工作路径。</param>
|
||||
/// <param name="outputPackageSelected">是否生成单机模式所需的文件。</param>
|
||||
/// <param name="outputPackagePath">为单机模式生成的文件存放于此路径。若游戏是单机游戏,生成结束后将此目录中对应平台的文件拷贝至 StreamingAssets 后打包 App 即可。</param>
|
||||
/// <param name="outputFullSelected">是否生成可更新模式所需的远程文件。</param>
|
||||
/// <param name="outputFullPath">为可更新模式生成的远程文件存放于此路径。若游戏是网络游戏,生成结束后应将此目录上传至 Web 服务器,供玩家下载用。</param>
|
||||
/// <param name="outputPackedSelected">是否生成可更新模式所需的本地文件。</param>
|
||||
/// <param name="outputPackedPath">为可更新模式生成的本地文件存放于此路径。若游戏是网络游戏,生成结束后将此目录中对应平台的文件拷贝至 StreamingAssets 后打包 App 即可。</param>
|
||||
/// <param name="buildReportPath">生成报告路径。</param>
|
||||
void OnPreprocessAllPlatforms(string productName, string companyName, string gameIdentifier, string gameFrameworkVersion, string unityVersion, string applicableGameVersion, int internalResourceVersion,
|
||||
Platform platforms, AssetBundleCompressionType assetBundleCompression, string compressionHelperTypeName, bool additionalCompressionSelected, bool forceRebuildAssetBundleSelected, string buildEventHandlerTypeName, string outputDirectory, BuildAssetBundleOptions buildAssetBundleOptions,
|
||||
string workingPath, bool outputPackageSelected, string outputPackagePath, bool outputFullSelected, string outputFullPath, bool outputPackedSelected, string outputPackedPath, string buildReportPath);
|
||||
|
||||
/// <summary>
|
||||
/// 某个平台生成开始前的预处理事件。
|
||||
/// </summary>
|
||||
/// <param name="platform">生成平台。</param>
|
||||
/// <param name="workingPath">生成时的工作路径。</param>
|
||||
/// <param name="outputPackageSelected">是否生成单机模式所需的文件。</param>
|
||||
/// <param name="outputPackagePath">为单机模式生成的文件存放于此路径。若游戏是单机游戏,生成结束后将此目录中对应平台的文件拷贝至 StreamingAssets 后打包 App 即可。</param>
|
||||
/// <param name="outputFullSelected">是否生成可更新模式所需的远程文件。</param>
|
||||
/// <param name="outputFullPath">为可更新模式生成的远程文件存放于此路径。若游戏是网络游戏,生成结束后应将此目录上传至 Web 服务器,供玩家下载用。</param>
|
||||
/// <param name="outputPackedSelected">是否生成可更新模式所需的本地文件。</param>
|
||||
/// <param name="outputPackedPath">为可更新模式生成的本地文件存放于此路径。若游戏是网络游戏,生成结束后将此目录中对应平台的文件拷贝至 StreamingAssets 后打包 App 即可。</param>
|
||||
void OnPreprocessPlatform(Platform platform, string workingPath, bool outputPackageSelected, string outputPackagePath, bool outputFullSelected, string outputFullPath, bool outputPackedSelected, string outputPackedPath);
|
||||
|
||||
/// <summary>
|
||||
/// 某个平台生成 AssetBundle 完成事件。
|
||||
/// </summary>
|
||||
/// <param name="platform">生成平台。</param>
|
||||
/// <param name="workingPath">生成时的工作路径。</param>
|
||||
/// <param name="outputPackageSelected">是否生成单机模式所需的文件。</param>
|
||||
/// <param name="outputPackagePath">为单机模式生成的文件存放于此路径。若游戏是单机游戏,生成结束后将此目录中对应平台的文件拷贝至 StreamingAssets 后打包 App 即可。</param>
|
||||
/// <param name="outputFullSelected">是否生成可更新模式所需的远程文件。</param>
|
||||
/// <param name="outputFullPath">为可更新模式生成的远程文件存放于此路径。若游戏是网络游戏,生成结束后应将此目录上传至 Web 服务器,供玩家下载用。</param>
|
||||
/// <param name="outputPackedSelected">是否生成可更新模式所需的本地文件。</param>
|
||||
/// <param name="outputPackedPath">为可更新模式生成的本地文件存放于此路径。若游戏是网络游戏,生成结束后将此目录中对应平台的文件拷贝至 StreamingAssets 后打包 App 即可。</param>
|
||||
/// <param name="assetBundleManifest">AssetBundle 的描述文件。</param>
|
||||
void OnBuildAssetBundlesComplete(Platform platform, string workingPath, bool outputPackageSelected, string outputPackagePath, bool outputFullSelected, string outputFullPath, bool outputPackedSelected, string outputPackedPath, AssetBundleManifest assetBundleManifest);
|
||||
|
||||
/// <summary>
|
||||
/// 某个平台可更新模式版本列表文件的输出事件。
|
||||
/// </summary>
|
||||
/// <param name="platform">生成平台。</param>
|
||||
/// <param name="versionListPath">可更新模式版本列表文件的路径。</param>
|
||||
/// <param name="versionListLength">可更新模式版本列表文件的长度。</param>
|
||||
/// <param name="versionListHashCode">可更新模式版本列表文件的校验值。</param>
|
||||
/// <param name="versionListCompressedLength">可更新模式版本列表文件压缩后的长度。</param>
|
||||
/// <param name="versionListCompressedHashCode">可更新模式版本列表文件压缩后的校验值。</param>
|
||||
void OnOutputUpdatableVersionListData(Platform platform, string versionListPath, int versionListLength, int versionListHashCode, int versionListCompressedLength, int versionListCompressedHashCode);
|
||||
|
||||
/// <summary>
|
||||
/// 某个平台生成结束后的后处理事件。
|
||||
/// </summary>
|
||||
/// <param name="platform">生成平台。</param>
|
||||
/// <param name="workingPath">生成时的工作路径。</param>
|
||||
/// <param name="outputPackageSelected">是否生成单机模式所需的文件。</param>
|
||||
/// <param name="outputPackagePath">为单机模式生成的文件存放于此路径。若游戏是单机游戏,生成结束后将此目录中对应平台的文件拷贝至 StreamingAssets 后打包 App 即可。</param>
|
||||
/// <param name="outputFullSelected">是否生成可更新模式所需的远程文件。</param>
|
||||
/// <param name="outputFullPath">为可更新模式生成的远程文件存放于此路径。若游戏是网络游戏,生成结束后应将此目录上传至 Web 服务器,供玩家下载用。</param>
|
||||
/// <param name="outputPackedSelected">是否生成可更新模式所需的本地文件。</param>
|
||||
/// <param name="outputPackedPath">为可更新模式生成的本地文件存放于此路径。若游戏是网络游戏,生成结束后将此目录中对应平台的文件拷贝至 StreamingAssets 后打包 App 即可。</param>
|
||||
/// <param name="isSuccess">是否生成成功。</param>
|
||||
void OnPostprocessPlatform(Platform platform, string workingPath, bool outputPackageSelected, string outputPackagePath, bool outputFullSelected, string outputFullPath, bool outputPackedSelected, string outputPackedPath, bool isSuccess);
|
||||
|
||||
/// <summary>
|
||||
/// 所有平台生成结束后的后处理事件。
|
||||
/// </summary>
|
||||
/// <param name="productName">产品名称。</param>
|
||||
/// <param name="companyName">公司名称。</param>
|
||||
/// <param name="gameIdentifier">游戏识别号。</param>
|
||||
/// <param name="gameFrameworkVersion">游戏框架版本。</param>
|
||||
/// <param name="unityVersion">Unity 版本。</param>
|
||||
/// <param name="applicableGameVersion">适用游戏版本。</param>
|
||||
/// <param name="internalResourceVersion">内部资源版本。</param>
|
||||
/// <param name="platforms">生成的目标平台。</param>
|
||||
/// <param name="assetBundleCompression">AssetBundle 压缩类型。</param>
|
||||
/// <param name="compressionHelperTypeName">压缩解压缩辅助器类型名称。</param>
|
||||
/// <param name="additionalCompressionSelected">是否进行再压缩以降低传输开销。</param>
|
||||
/// <param name="forceRebuildAssetBundleSelected">是否强制重新构建 AssetBundle。</param>
|
||||
/// <param name="buildEventHandlerTypeName">生成资源事件处理函数名称。</param>
|
||||
/// <param name="outputDirectory">生成目录。</param>
|
||||
/// <param name="buildAssetBundleOptions">AssetBundle 生成选项。</param>
|
||||
/// <param name="workingPath">生成时的工作路径。</param>
|
||||
/// <param name="outputPackageSelected">是否生成单机模式所需的文件。</param>
|
||||
/// <param name="outputPackagePath">为单机模式生成的文件存放于此路径。若游戏是单机游戏,生成结束后将此目录中对应平台的文件拷贝至 StreamingAssets 后打包 App 即可。</param>
|
||||
/// <param name="outputFullSelected">是否生成可更新模式所需的远程文件。</param>
|
||||
/// <param name="outputFullPath">为可更新模式生成的远程文件存放于此路径。若游戏是网络游戏,生成结束后应将此目录上传至 Web 服务器,供玩家下载用。</param>
|
||||
/// <param name="outputPackedSelected">是否生成可更新模式所需的本地文件。</param>
|
||||
/// <param name="outputPackedPath">为可更新模式生成的本地文件存放于此路径。若游戏是网络游戏,生成结束后将此目录中对应平台的文件拷贝至 StreamingAssets 后打包 App 即可。</param>
|
||||
/// <param name="buildReportPath">生成报告路径。</param>
|
||||
void OnPostprocessAllPlatforms(string productName, string companyName, string gameIdentifier, string gameFrameworkVersion, string unityVersion, string applicableGameVersion, int internalResourceVersion,
|
||||
Platform platforms, AssetBundleCompressionType assetBundleCompression, string compressionHelperTypeName, bool additionalCompressionSelected, bool forceRebuildAssetBundleSelected, string buildEventHandlerTypeName, string outputDirectory, BuildAssetBundleOptions buildAssetBundleOptions,
|
||||
string workingPath, bool outputPackageSelected, string outputPackagePath, bool outputFullSelected, string outputFullPath, bool outputPackedSelected, string outputPackedPath, string buildReportPath);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a24c2d69ef707e94c8ec819667089bce
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,57 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
|
||||
namespace UnityGameFramework.Editor.ResourceTools
|
||||
{
|
||||
[Flags]
|
||||
public enum Platform : int
|
||||
{
|
||||
Undefined = 0,
|
||||
|
||||
/// <summary>
|
||||
/// Windows 32 位。
|
||||
/// </summary>
|
||||
Windows = 1 << 0,
|
||||
|
||||
/// <summary>
|
||||
/// Windows 64 位。
|
||||
/// </summary>
|
||||
Windows64 = 1 << 1,
|
||||
|
||||
/// <summary>
|
||||
/// macOS。
|
||||
/// </summary>
|
||||
MacOS = 1 << 2,
|
||||
|
||||
/// <summary>
|
||||
/// Linux。
|
||||
/// </summary>
|
||||
Linux = 1 << 3,
|
||||
|
||||
/// <summary>
|
||||
/// iOS。
|
||||
/// </summary>
|
||||
IOS = 1 << 4,
|
||||
|
||||
/// <summary>
|
||||
/// Android。
|
||||
/// </summary>
|
||||
Android = 1 << 5,
|
||||
|
||||
/// <summary>
|
||||
/// Windows Store。
|
||||
/// </summary>
|
||||
WindowsStore = 1 << 6,
|
||||
|
||||
/// <summary>
|
||||
/// WebGL。
|
||||
/// </summary>
|
||||
WebGL = 1 << 7,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 443d82794c390e043b1565cea8da60cd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,513 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using GameFramework;
|
||||
using System;
|
||||
using System.IO;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityGameFramework.Editor.ResourceTools
|
||||
{
|
||||
/// <summary>
|
||||
/// 资源生成器。
|
||||
/// </summary>
|
||||
internal sealed class ResourceBuilder : EditorWindow
|
||||
{
|
||||
private ResourceBuilderController m_Controller = null;
|
||||
private bool m_OrderBuildResources = false;
|
||||
private int m_CompressionHelperTypeNameIndex = 0;
|
||||
private int m_BuildEventHandlerTypeNameIndex = 0;
|
||||
|
||||
[MenuItem("Game Framework/Resource Tools/Resource Builder", false, 40)]
|
||||
private static void Open()
|
||||
{
|
||||
ResourceBuilder window = GetWindow<ResourceBuilder>("Resource Builder", true);
|
||||
#if UNITY_2019_3_OR_NEWER
|
||||
window.minSize = new Vector2(800f, 640f);
|
||||
#else
|
||||
window.minSize = new Vector2(800f, 600f);
|
||||
#endif
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
m_Controller = new ResourceBuilderController();
|
||||
m_Controller.OnLoadingResource += OnLoadingResource;
|
||||
m_Controller.OnLoadingAsset += OnLoadingAsset;
|
||||
m_Controller.OnLoadCompleted += OnLoadCompleted;
|
||||
m_Controller.OnAnalyzingAsset += OnAnalyzingAsset;
|
||||
m_Controller.OnAnalyzeCompleted += OnAnalyzeCompleted;
|
||||
m_Controller.ProcessingAssetBundle += OnProcessingAssetBundle;
|
||||
m_Controller.ProcessingBinary += OnProcessingBinary;
|
||||
m_Controller.ProcessResourceComplete += OnProcessResourceComplete;
|
||||
m_Controller.BuildResourceError += OnBuildResourceError;
|
||||
|
||||
m_OrderBuildResources = false;
|
||||
|
||||
if (m_Controller.Load())
|
||||
{
|
||||
Debug.Log("Load configuration success.");
|
||||
|
||||
m_CompressionHelperTypeNameIndex = 0;
|
||||
string[] compressionHelperTypeNames = m_Controller.GetCompressionHelperTypeNames();
|
||||
for (int i = 0; i < compressionHelperTypeNames.Length; i++)
|
||||
{
|
||||
if (m_Controller.CompressionHelperTypeName == compressionHelperTypeNames[i])
|
||||
{
|
||||
m_CompressionHelperTypeNameIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
m_Controller.RefreshCompressionHelper();
|
||||
|
||||
m_BuildEventHandlerTypeNameIndex = 0;
|
||||
string[] buildEventHandlerTypeNames = m_Controller.GetBuildEventHandlerTypeNames();
|
||||
for (int i = 0; i < buildEventHandlerTypeNames.Length; i++)
|
||||
{
|
||||
if (m_Controller.BuildEventHandlerTypeName == buildEventHandlerTypeNames[i])
|
||||
{
|
||||
m_BuildEventHandlerTypeNameIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
m_Controller.RefreshBuildEventHandler();
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning("Load configuration failure.");
|
||||
}
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (m_OrderBuildResources)
|
||||
{
|
||||
m_OrderBuildResources = false;
|
||||
BuildResources();
|
||||
}
|
||||
}
|
||||
|
||||
private void OnGUI()
|
||||
{
|
||||
EditorGUILayout.BeginVertical(GUILayout.Width(position.width), GUILayout.Height(position.height));
|
||||
{
|
||||
GUILayout.Space(5f);
|
||||
EditorGUILayout.LabelField("Environment Information", EditorStyles.boldLabel);
|
||||
EditorGUILayout.BeginVertical("box");
|
||||
{
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
{
|
||||
EditorGUILayout.LabelField("Product Name", GUILayout.Width(160f));
|
||||
EditorGUILayout.LabelField(m_Controller.ProductName);
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
{
|
||||
EditorGUILayout.LabelField("Company Name", GUILayout.Width(160f));
|
||||
EditorGUILayout.LabelField(m_Controller.CompanyName);
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
{
|
||||
EditorGUILayout.LabelField("Game Identifier", GUILayout.Width(160f));
|
||||
EditorGUILayout.LabelField(m_Controller.GameIdentifier);
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
{
|
||||
EditorGUILayout.LabelField("Game Framework Version", GUILayout.Width(160f));
|
||||
EditorGUILayout.LabelField(m_Controller.GameFrameworkVersion);
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
{
|
||||
EditorGUILayout.LabelField("Unity Version", GUILayout.Width(160f));
|
||||
EditorGUILayout.LabelField(m_Controller.UnityVersion);
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
{
|
||||
EditorGUILayout.LabelField("Applicable Game Version", GUILayout.Width(160f));
|
||||
EditorGUILayout.LabelField(m_Controller.ApplicableGameVersion);
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
}
|
||||
EditorGUILayout.EndVertical();
|
||||
GUILayout.Space(5f);
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
{
|
||||
EditorGUILayout.BeginVertical();
|
||||
{
|
||||
EditorGUILayout.LabelField("Platforms", EditorStyles.boldLabel);
|
||||
EditorGUILayout.BeginHorizontal("box");
|
||||
{
|
||||
EditorGUILayout.BeginVertical();
|
||||
{
|
||||
DrawPlatform(Platform.Windows, "Windows");
|
||||
DrawPlatform(Platform.Windows64, "Windows x64");
|
||||
DrawPlatform(Platform.MacOS, "macOS");
|
||||
}
|
||||
EditorGUILayout.EndVertical();
|
||||
EditorGUILayout.BeginVertical();
|
||||
{
|
||||
DrawPlatform(Platform.Linux, "Linux");
|
||||
DrawPlatform(Platform.IOS, "iOS");
|
||||
DrawPlatform(Platform.Android, "Android");
|
||||
}
|
||||
EditorGUILayout.EndVertical();
|
||||
EditorGUILayout.BeginVertical();
|
||||
{
|
||||
DrawPlatform(Platform.WindowsStore, "Windows Store");
|
||||
DrawPlatform(Platform.WebGL, "WebGL");
|
||||
}
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
}
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
GUILayout.Space(5f);
|
||||
EditorGUILayout.LabelField("Compression", EditorStyles.boldLabel);
|
||||
EditorGUILayout.BeginVertical("box");
|
||||
{
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
{
|
||||
EditorGUILayout.LabelField("AssetBundle Compression", GUILayout.Width(160f));
|
||||
m_Controller.AssetBundleCompression = (AssetBundleCompressionType)EditorGUILayout.EnumPopup(m_Controller.AssetBundleCompression);
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
{
|
||||
EditorGUILayout.LabelField("Compression Helper", GUILayout.Width(160f));
|
||||
string[] names = m_Controller.GetCompressionHelperTypeNames();
|
||||
int selectedIndex = EditorGUILayout.Popup(m_CompressionHelperTypeNameIndex, names);
|
||||
if (selectedIndex != m_CompressionHelperTypeNameIndex)
|
||||
{
|
||||
m_CompressionHelperTypeNameIndex = selectedIndex;
|
||||
m_Controller.CompressionHelperTypeName = selectedIndex <= 0 ? string.Empty : names[selectedIndex];
|
||||
if (m_Controller.RefreshCompressionHelper())
|
||||
{
|
||||
Debug.Log("Set compression helper success.");
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning("Set compression helper failure.");
|
||||
}
|
||||
}
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
{
|
||||
EditorGUILayout.LabelField("Additional Compression", GUILayout.Width(160f));
|
||||
m_Controller.AdditionalCompressionSelected = EditorGUILayout.ToggleLeft("Additional Compression for Output Full Resources with Compression Helper", m_Controller.AdditionalCompressionSelected);
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
}
|
||||
EditorGUILayout.EndVertical();
|
||||
GUILayout.Space(5f);
|
||||
EditorGUILayout.LabelField("Build", EditorStyles.boldLabel);
|
||||
EditorGUILayout.BeginVertical("box");
|
||||
{
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
{
|
||||
EditorGUILayout.LabelField("Force Rebuild AssetBundle", GUILayout.Width(160f));
|
||||
m_Controller.ForceRebuildAssetBundleSelected = EditorGUILayout.Toggle(m_Controller.ForceRebuildAssetBundleSelected);
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
{
|
||||
EditorGUILayout.LabelField("Build Event Handler", GUILayout.Width(160f));
|
||||
string[] names = m_Controller.GetBuildEventHandlerTypeNames();
|
||||
int selectedIndex = EditorGUILayout.Popup(m_BuildEventHandlerTypeNameIndex, names);
|
||||
if (selectedIndex != m_BuildEventHandlerTypeNameIndex)
|
||||
{
|
||||
m_BuildEventHandlerTypeNameIndex = selectedIndex;
|
||||
m_Controller.BuildEventHandlerTypeName = selectedIndex <= 0 ? string.Empty : names[selectedIndex];
|
||||
if (m_Controller.RefreshBuildEventHandler())
|
||||
{
|
||||
Debug.Log("Set build event handler success.");
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning("Set build event handler failure.");
|
||||
}
|
||||
}
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
{
|
||||
EditorGUILayout.LabelField("Internal Resource Version", GUILayout.Width(160f));
|
||||
m_Controller.InternalResourceVersion = EditorGUILayout.IntField(m_Controller.InternalResourceVersion);
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
{
|
||||
EditorGUILayout.LabelField("Resource Version", GUILayout.Width(160f));
|
||||
GUILayout.Label(Utility.Text.Format("{0} ({1})", m_Controller.ApplicableGameVersion, m_Controller.InternalResourceVersion));
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
{
|
||||
EditorGUILayout.LabelField("Output Directory", GUILayout.Width(160f));
|
||||
m_Controller.OutputDirectory = EditorGUILayout.TextField(m_Controller.OutputDirectory);
|
||||
if (GUILayout.Button("Browse...", GUILayout.Width(80f)))
|
||||
{
|
||||
BrowseOutputDirectory();
|
||||
}
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
{
|
||||
EditorGUILayout.LabelField("Working Path", GUILayout.Width(160f));
|
||||
GUILayout.Label(m_Controller.WorkingPath);
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
{
|
||||
EditorGUI.BeginDisabledGroup(!m_Controller.OutputPackageSelected);
|
||||
EditorGUILayout.LabelField("Output Package Path", GUILayout.Width(160f));
|
||||
GUILayout.Label(m_Controller.OutputPackagePath);
|
||||
EditorGUI.EndDisabledGroup();
|
||||
m_Controller.OutputPackageSelected = EditorGUILayout.ToggleLeft("Generate", m_Controller.OutputPackageSelected, GUILayout.Width(70f));
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
{
|
||||
EditorGUI.BeginDisabledGroup(!m_Controller.OutputFullSelected);
|
||||
EditorGUILayout.LabelField("Output Full Path", GUILayout.Width(160f));
|
||||
GUILayout.Label(m_Controller.OutputFullPath);
|
||||
EditorGUI.EndDisabledGroup();
|
||||
m_Controller.OutputFullSelected = EditorGUILayout.ToggleLeft("Generate", m_Controller.OutputFullSelected, GUILayout.Width(70f));
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
{
|
||||
EditorGUI.BeginDisabledGroup(!m_Controller.OutputPackedSelected);
|
||||
EditorGUILayout.LabelField("Output Packed Path", GUILayout.Width(160f));
|
||||
GUILayout.Label(m_Controller.OutputPackedPath);
|
||||
EditorGUI.EndDisabledGroup();
|
||||
m_Controller.OutputPackedSelected = EditorGUILayout.ToggleLeft("Generate", m_Controller.OutputPackedSelected, GUILayout.Width(70f));
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
{
|
||||
EditorGUILayout.LabelField("Build Report Path", GUILayout.Width(160f));
|
||||
GUILayout.Label(m_Controller.BuildReportPath);
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
}
|
||||
EditorGUILayout.EndVertical();
|
||||
string buildMessage = string.Empty;
|
||||
MessageType buildMessageType = MessageType.None;
|
||||
GetBuildMessage(out buildMessage, out buildMessageType);
|
||||
EditorGUILayout.HelpBox(buildMessage, buildMessageType);
|
||||
GUILayout.Space(2f);
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
{
|
||||
EditorGUI.BeginDisabledGroup(m_Controller.Platforms == Platform.Undefined || string.IsNullOrEmpty(m_Controller.CompressionHelperTypeName) || !m_Controller.IsValidOutputDirectory);
|
||||
{
|
||||
if (GUILayout.Button("Start Build Resources"))
|
||||
{
|
||||
m_OrderBuildResources = true;
|
||||
}
|
||||
}
|
||||
EditorGUI.EndDisabledGroup();
|
||||
if (GUILayout.Button("Save", GUILayout.Width(80f)))
|
||||
{
|
||||
SaveConfiguration();
|
||||
}
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
}
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
|
||||
private void BrowseOutputDirectory()
|
||||
{
|
||||
string directory = EditorUtility.OpenFolderPanel("Select Output Directory", m_Controller.OutputDirectory, string.Empty);
|
||||
if (!string.IsNullOrEmpty(directory))
|
||||
{
|
||||
m_Controller.OutputDirectory = directory;
|
||||
}
|
||||
}
|
||||
|
||||
private void GetBuildMessage(out string message, out MessageType messageType)
|
||||
{
|
||||
message = string.Empty;
|
||||
messageType = MessageType.Error;
|
||||
if (m_Controller.Platforms == Platform.Undefined)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(message))
|
||||
{
|
||||
message += Environment.NewLine;
|
||||
}
|
||||
|
||||
message += "Platform is invalid.";
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(m_Controller.CompressionHelperTypeName))
|
||||
{
|
||||
if (!string.IsNullOrEmpty(message))
|
||||
{
|
||||
message += Environment.NewLine;
|
||||
}
|
||||
|
||||
message += "Compression helper is invalid.";
|
||||
}
|
||||
|
||||
if (!m_Controller.IsValidOutputDirectory)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(message))
|
||||
{
|
||||
message += Environment.NewLine;
|
||||
}
|
||||
|
||||
message += "Output directory is invalid.";
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(message))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
messageType = MessageType.Info;
|
||||
if (Directory.Exists(m_Controller.OutputPackagePath))
|
||||
{
|
||||
message += Utility.Text.Format("{0} will be overwritten.", m_Controller.OutputPackagePath);
|
||||
messageType = MessageType.Warning;
|
||||
}
|
||||
|
||||
if (Directory.Exists(m_Controller.OutputFullPath))
|
||||
{
|
||||
if (message.Length > 0)
|
||||
{
|
||||
message += " ";
|
||||
}
|
||||
|
||||
message += Utility.Text.Format("{0} will be overwritten.", m_Controller.OutputFullPath);
|
||||
messageType = MessageType.Warning;
|
||||
}
|
||||
|
||||
if (Directory.Exists(m_Controller.OutputPackedPath))
|
||||
{
|
||||
if (message.Length > 0)
|
||||
{
|
||||
message += " ";
|
||||
}
|
||||
|
||||
message += Utility.Text.Format("{0} will be overwritten.", m_Controller.OutputPackedPath);
|
||||
messageType = MessageType.Warning;
|
||||
}
|
||||
|
||||
if (messageType == MessageType.Warning)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
message = "Ready to build.";
|
||||
}
|
||||
|
||||
private void BuildResources()
|
||||
{
|
||||
if (m_Controller.BuildResources())
|
||||
{
|
||||
Debug.Log("Build resources success.");
|
||||
SaveConfiguration();
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning("Build resources failure.");
|
||||
}
|
||||
}
|
||||
|
||||
private void SaveConfiguration()
|
||||
{
|
||||
if (m_Controller.Save())
|
||||
{
|
||||
Debug.Log("Save configuration success.");
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning("Save configuration failure.");
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawPlatform(Platform platform, string platformName)
|
||||
{
|
||||
m_Controller.SelectPlatform(platform, EditorGUILayout.ToggleLeft(platformName, m_Controller.IsPlatformSelected(platform)));
|
||||
}
|
||||
|
||||
private void OnLoadingResource(int index, int count)
|
||||
{
|
||||
EditorUtility.DisplayProgressBar("Loading Resources", Utility.Text.Format("Loading resources, {0}/{1} loaded.", index, count), (float)index / count);
|
||||
}
|
||||
|
||||
private void OnLoadingAsset(int index, int count)
|
||||
{
|
||||
EditorUtility.DisplayProgressBar("Loading Assets", Utility.Text.Format("Loading assets, {0}/{1} loaded.", index, count), (float)index / count);
|
||||
}
|
||||
|
||||
private void OnLoadCompleted()
|
||||
{
|
||||
EditorUtility.ClearProgressBar();
|
||||
}
|
||||
|
||||
private void OnAnalyzingAsset(int index, int count)
|
||||
{
|
||||
EditorUtility.DisplayProgressBar("Analyzing Assets", Utility.Text.Format("Analyzing assets, {0}/{1} analyzed.", index, count), (float)index / count);
|
||||
}
|
||||
|
||||
private void OnAnalyzeCompleted()
|
||||
{
|
||||
EditorUtility.ClearProgressBar();
|
||||
}
|
||||
|
||||
private bool OnProcessingAssetBundle(string assetBundleName, float progress)
|
||||
{
|
||||
if (EditorUtility.DisplayCancelableProgressBar("Processing AssetBundle", Utility.Text.Format("Processing '{0}'...", assetBundleName), progress))
|
||||
{
|
||||
EditorUtility.ClearProgressBar();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Repaint();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private bool OnProcessingBinary(string binaryName, float progress)
|
||||
{
|
||||
if (EditorUtility.DisplayCancelableProgressBar("Processing Binary", Utility.Text.Format("Processing '{0}'...", binaryName), progress))
|
||||
{
|
||||
EditorUtility.ClearProgressBar();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Repaint();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnProcessResourceComplete(Platform platform)
|
||||
{
|
||||
EditorUtility.ClearProgressBar();
|
||||
Debug.Log(Utility.Text.Format("Build resources for '{0}' complete.", platform));
|
||||
}
|
||||
|
||||
private void OnBuildResourceError(string errorMessage)
|
||||
{
|
||||
EditorUtility.ClearProgressBar();
|
||||
Debug.LogWarning(Utility.Text.Format("Build resources error with error message '{0}'.", errorMessage));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e863c5f9e4c0a9d47a926fbb0416a149
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
namespace UnityGameFramework.Editor.ResourceTools
|
||||
{
|
||||
/// <summary>
|
||||
/// ResourceBuilder 配置路径属性。
|
||||
/// </summary>
|
||||
public sealed class ResourceBuilderConfigPathAttribute : ConfigPathAttribute
|
||||
{
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 099a19e921c6da944ba2cdf51139d818
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+67
@@ -0,0 +1,67 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
namespace UnityGameFramework.Editor.ResourceTools
|
||||
{
|
||||
public sealed partial class ResourceBuilderController
|
||||
{
|
||||
private sealed class AssetData
|
||||
{
|
||||
private readonly string m_Guid;
|
||||
private readonly string m_Name;
|
||||
private readonly int m_Length;
|
||||
private readonly int m_HashCode;
|
||||
private readonly string[] m_DependencyAssetNames;
|
||||
|
||||
public AssetData(string guid, string name, int length, int hashCode, string[] dependencyAssetNames)
|
||||
{
|
||||
m_Guid = guid;
|
||||
m_Name = name;
|
||||
m_Length = length;
|
||||
m_HashCode = hashCode;
|
||||
m_DependencyAssetNames = dependencyAssetNames;
|
||||
}
|
||||
|
||||
public string Guid
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Guid;
|
||||
}
|
||||
}
|
||||
|
||||
public string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Name;
|
||||
}
|
||||
}
|
||||
|
||||
public int Length
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Length;
|
||||
}
|
||||
}
|
||||
|
||||
public int HashCode
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_HashCode;
|
||||
}
|
||||
}
|
||||
|
||||
public string[] GetDependencyAssetNames()
|
||||
{
|
||||
return m_DependencyAssetNames;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b52ab112713ba504a84693edd59a6b03
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+276
@@ -0,0 +1,276 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using GameFramework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Xml;
|
||||
using UnityEditor;
|
||||
|
||||
namespace UnityGameFramework.Editor.ResourceTools
|
||||
{
|
||||
public sealed partial class ResourceBuilderController
|
||||
{
|
||||
private sealed class BuildReport
|
||||
{
|
||||
private const string BuildReportName = "BuildReport.xml";
|
||||
private const string BuildLogName = "BuildLog.txt";
|
||||
|
||||
private string m_BuildReportName = null;
|
||||
private string m_BuildLogName = null;
|
||||
private string m_ProductName = null;
|
||||
private string m_CompanyName = null;
|
||||
private string m_GameIdentifier = null;
|
||||
private string m_GameFrameworkVersion = null;
|
||||
private string m_UnityVersion = null;
|
||||
private string m_ApplicableGameVersion = null;
|
||||
private int m_InternalResourceVersion = 0;
|
||||
private Platform m_Platforms = Platform.Undefined;
|
||||
private AssetBundleCompressionType m_AssetBundleCompression;
|
||||
private string m_CompressionHelperTypeName;
|
||||
private bool m_AdditionalCompressionSelected = false;
|
||||
private bool m_ForceRebuildAssetBundleSelected = false;
|
||||
private string m_BuildEventHandlerTypeName;
|
||||
private string m_OutputDirectory;
|
||||
private BuildAssetBundleOptions m_BuildAssetBundleOptions = BuildAssetBundleOptions.None;
|
||||
private StringBuilder m_LogBuilder = null;
|
||||
private SortedDictionary<string, ResourceData> m_ResourceDatas = null;
|
||||
|
||||
public void Initialize(string buildReportPath, string productName, string companyName, string gameIdentifier, string gameFrameworkVersion, string unityVersion, string applicableGameVersion, int internalResourceVersion,
|
||||
Platform platforms, AssetBundleCompressionType assetBundleCompression, string compressionHelperTypeName, bool additionalCompressionSelected, bool forceRebuildAssetBundleSelected, string buildEventHandlerTypeName, string outputDirectory, BuildAssetBundleOptions buildAssetBundleOptions, SortedDictionary<string, ResourceData> resourceDatas)
|
||||
{
|
||||
if (string.IsNullOrEmpty(buildReportPath))
|
||||
{
|
||||
throw new GameFrameworkException("Build report path is invalid.");
|
||||
}
|
||||
|
||||
m_BuildReportName = Utility.Path.GetRegularPath(Path.Combine(buildReportPath, BuildReportName));
|
||||
m_BuildLogName = Utility.Path.GetRegularPath(Path.Combine(buildReportPath, BuildLogName));
|
||||
m_ProductName = productName;
|
||||
m_CompanyName = companyName;
|
||||
m_GameIdentifier = gameIdentifier;
|
||||
m_GameFrameworkVersion = gameFrameworkVersion;
|
||||
m_UnityVersion = unityVersion;
|
||||
m_ApplicableGameVersion = applicableGameVersion;
|
||||
m_InternalResourceVersion = internalResourceVersion;
|
||||
m_Platforms = platforms;
|
||||
m_AssetBundleCompression = assetBundleCompression;
|
||||
m_CompressionHelperTypeName = compressionHelperTypeName;
|
||||
m_AdditionalCompressionSelected = additionalCompressionSelected;
|
||||
m_ForceRebuildAssetBundleSelected = forceRebuildAssetBundleSelected;
|
||||
m_BuildEventHandlerTypeName = buildEventHandlerTypeName;
|
||||
m_OutputDirectory = outputDirectory;
|
||||
m_BuildAssetBundleOptions = buildAssetBundleOptions;
|
||||
m_LogBuilder = new StringBuilder();
|
||||
m_ResourceDatas = resourceDatas;
|
||||
}
|
||||
|
||||
public void LogInfo(string format, params object[] args)
|
||||
{
|
||||
LogInternal("INFO", format, args);
|
||||
}
|
||||
|
||||
public void LogWarning(string format, params object[] args)
|
||||
{
|
||||
LogInternal("WARNING", format, args);
|
||||
}
|
||||
|
||||
public void LogError(string format, params object[] args)
|
||||
{
|
||||
LogInternal("ERROR", format, args);
|
||||
}
|
||||
|
||||
public void LogFatal(string format, params object[] args)
|
||||
{
|
||||
LogInternal("FATAL", format, args);
|
||||
}
|
||||
|
||||
public void SaveReport()
|
||||
{
|
||||
XmlElement xmlElement = null;
|
||||
XmlAttribute xmlAttribute = null;
|
||||
|
||||
XmlDocument xmlDocument = new XmlDocument();
|
||||
xmlDocument.AppendChild(xmlDocument.CreateXmlDeclaration("1.0", "UTF-8", null));
|
||||
|
||||
XmlElement xmlRoot = xmlDocument.CreateElement("UnityGameFramework");
|
||||
xmlDocument.AppendChild(xmlRoot);
|
||||
|
||||
XmlElement xmlBuildReport = xmlDocument.CreateElement("BuildReport");
|
||||
xmlRoot.AppendChild(xmlBuildReport);
|
||||
|
||||
XmlElement xmlSummary = xmlDocument.CreateElement("Summary");
|
||||
xmlBuildReport.AppendChild(xmlSummary);
|
||||
|
||||
xmlElement = xmlDocument.CreateElement("ProductName");
|
||||
xmlElement.InnerText = m_ProductName;
|
||||
xmlSummary.AppendChild(xmlElement);
|
||||
xmlElement = xmlDocument.CreateElement("CompanyName");
|
||||
xmlElement.InnerText = m_CompanyName;
|
||||
xmlSummary.AppendChild(xmlElement);
|
||||
xmlElement = xmlDocument.CreateElement("GameIdentifier");
|
||||
xmlElement.InnerText = m_GameIdentifier;
|
||||
xmlSummary.AppendChild(xmlElement);
|
||||
xmlElement = xmlDocument.CreateElement("GameFrameworkVersion");
|
||||
xmlElement.InnerText = m_GameFrameworkVersion;
|
||||
xmlSummary.AppendChild(xmlElement);
|
||||
xmlElement = xmlDocument.CreateElement("UnityVersion");
|
||||
xmlElement.InnerText = m_UnityVersion;
|
||||
xmlSummary.AppendChild(xmlElement);
|
||||
xmlElement = xmlDocument.CreateElement("ApplicableGameVersion");
|
||||
xmlElement.InnerText = m_ApplicableGameVersion;
|
||||
xmlSummary.AppendChild(xmlElement);
|
||||
xmlElement = xmlDocument.CreateElement("InternalResourceVersion");
|
||||
xmlElement.InnerText = m_InternalResourceVersion.ToString();
|
||||
xmlSummary.AppendChild(xmlElement);
|
||||
xmlElement = xmlDocument.CreateElement("Platforms");
|
||||
xmlElement.InnerText = m_Platforms.ToString();
|
||||
xmlSummary.AppendChild(xmlElement);
|
||||
xmlElement = xmlDocument.CreateElement("AssetBundleCompression");
|
||||
xmlElement.InnerText = m_AssetBundleCompression.ToString();
|
||||
xmlSummary.AppendChild(xmlElement);
|
||||
xmlElement = xmlDocument.CreateElement("CompressionHelperTypeName");
|
||||
xmlElement.InnerText = m_CompressionHelperTypeName;
|
||||
xmlSummary.AppendChild(xmlElement);
|
||||
xmlElement = xmlDocument.CreateElement("AdditionalCompressionSelected");
|
||||
xmlElement.InnerText = m_AdditionalCompressionSelected.ToString();
|
||||
xmlSummary.AppendChild(xmlElement);
|
||||
xmlElement = xmlDocument.CreateElement("ForceRebuildAssetBundleSelected");
|
||||
xmlElement.InnerText = m_ForceRebuildAssetBundleSelected.ToString();
|
||||
xmlSummary.AppendChild(xmlElement);
|
||||
xmlElement = xmlDocument.CreateElement("BuildEventHandlerTypeName");
|
||||
xmlElement.InnerText = m_BuildEventHandlerTypeName;
|
||||
xmlSummary.AppendChild(xmlElement);
|
||||
xmlElement = xmlDocument.CreateElement("OutputDirectory");
|
||||
xmlElement.InnerText = m_OutputDirectory;
|
||||
xmlSummary.AppendChild(xmlElement);
|
||||
xmlElement = xmlDocument.CreateElement("BuildAssetBundleOptions");
|
||||
xmlElement.InnerText = m_BuildAssetBundleOptions.ToString();
|
||||
xmlSummary.AppendChild(xmlElement);
|
||||
|
||||
XmlElement xmlResources = xmlDocument.CreateElement("Resources");
|
||||
xmlAttribute = xmlDocument.CreateAttribute("Count");
|
||||
xmlAttribute.Value = m_ResourceDatas.Count.ToString();
|
||||
xmlResources.Attributes.SetNamedItem(xmlAttribute);
|
||||
xmlBuildReport.AppendChild(xmlResources);
|
||||
foreach (ResourceData resourceData in m_ResourceDatas.Values)
|
||||
{
|
||||
XmlElement xmlResource = xmlDocument.CreateElement("Resource");
|
||||
xmlAttribute = xmlDocument.CreateAttribute("Name");
|
||||
xmlAttribute.Value = resourceData.Name;
|
||||
xmlResource.Attributes.SetNamedItem(xmlAttribute);
|
||||
if (resourceData.Variant != null)
|
||||
{
|
||||
xmlAttribute = xmlDocument.CreateAttribute("Variant");
|
||||
xmlAttribute.Value = resourceData.Variant;
|
||||
xmlResource.Attributes.SetNamedItem(xmlAttribute);
|
||||
}
|
||||
|
||||
xmlAttribute = xmlDocument.CreateAttribute("Extension");
|
||||
xmlAttribute.Value = GetExtension(resourceData);
|
||||
xmlResource.Attributes.SetNamedItem(xmlAttribute);
|
||||
|
||||
if (resourceData.FileSystem != null)
|
||||
{
|
||||
xmlAttribute = xmlDocument.CreateAttribute("FileSystem");
|
||||
xmlAttribute.Value = resourceData.FileSystem;
|
||||
xmlResource.Attributes.SetNamedItem(xmlAttribute);
|
||||
}
|
||||
|
||||
xmlAttribute = xmlDocument.CreateAttribute("LoadType");
|
||||
xmlAttribute.Value = ((byte)resourceData.LoadType).ToString();
|
||||
xmlResource.Attributes.SetNamedItem(xmlAttribute);
|
||||
xmlAttribute = xmlDocument.CreateAttribute("Packed");
|
||||
xmlAttribute.Value = resourceData.Packed.ToString();
|
||||
xmlResource.Attributes.SetNamedItem(xmlAttribute);
|
||||
string[] resourceGroups = resourceData.GetResourceGroups();
|
||||
if (resourceGroups.Length > 0)
|
||||
{
|
||||
xmlAttribute = xmlDocument.CreateAttribute("ResourceGroups");
|
||||
xmlAttribute.Value = string.Join(",", resourceGroups);
|
||||
xmlResource.Attributes.SetNamedItem(xmlAttribute);
|
||||
}
|
||||
|
||||
xmlResources.AppendChild(xmlResource);
|
||||
|
||||
AssetData[] assetDatas = resourceData.GetAssetDatas();
|
||||
XmlElement xmlAssets = xmlDocument.CreateElement("Assets");
|
||||
xmlAttribute = xmlDocument.CreateAttribute("Count");
|
||||
xmlAttribute.Value = assetDatas.Length.ToString();
|
||||
xmlAssets.Attributes.SetNamedItem(xmlAttribute);
|
||||
xmlResource.AppendChild(xmlAssets);
|
||||
foreach (AssetData assetData in assetDatas)
|
||||
{
|
||||
XmlElement xmlAsset = xmlDocument.CreateElement("Asset");
|
||||
xmlAttribute = xmlDocument.CreateAttribute("Guid");
|
||||
xmlAttribute.Value = assetData.Guid;
|
||||
xmlAsset.Attributes.SetNamedItem(xmlAttribute);
|
||||
xmlAttribute = xmlDocument.CreateAttribute("Name");
|
||||
xmlAttribute.Value = assetData.Name;
|
||||
xmlAsset.Attributes.SetNamedItem(xmlAttribute);
|
||||
xmlAttribute = xmlDocument.CreateAttribute("Length");
|
||||
xmlAttribute.Value = assetData.Length.ToString();
|
||||
xmlAsset.Attributes.SetNamedItem(xmlAttribute);
|
||||
xmlAttribute = xmlDocument.CreateAttribute("HashCode");
|
||||
xmlAttribute.Value = assetData.HashCode.ToString();
|
||||
xmlAsset.Attributes.SetNamedItem(xmlAttribute);
|
||||
xmlAssets.AppendChild(xmlAsset);
|
||||
string[] dependencyAssetNames = assetData.GetDependencyAssetNames();
|
||||
if (dependencyAssetNames.Length > 0)
|
||||
{
|
||||
XmlElement xmlDependencyAssets = xmlDocument.CreateElement("DependencyAssets");
|
||||
xmlAttribute = xmlDocument.CreateAttribute("Count");
|
||||
xmlAttribute.Value = dependencyAssetNames.Length.ToString();
|
||||
xmlDependencyAssets.Attributes.SetNamedItem(xmlAttribute);
|
||||
xmlAsset.AppendChild(xmlDependencyAssets);
|
||||
foreach (string dependencyAssetName in dependencyAssetNames)
|
||||
{
|
||||
XmlElement xmlDependencyAsset = xmlDocument.CreateElement("DependencyAsset");
|
||||
xmlAttribute = xmlDocument.CreateAttribute("Name");
|
||||
xmlAttribute.Value = dependencyAssetName;
|
||||
xmlDependencyAsset.Attributes.SetNamedItem(xmlAttribute);
|
||||
xmlDependencyAssets.AppendChild(xmlDependencyAsset);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
XmlElement xmlCodes = xmlDocument.CreateElement("Codes");
|
||||
xmlResource.AppendChild(xmlCodes);
|
||||
foreach (ResourceCode resourceCode in resourceData.GetCodes())
|
||||
{
|
||||
XmlElement xmlCode = xmlDocument.CreateElement(resourceCode.Platform.ToString());
|
||||
xmlAttribute = xmlDocument.CreateAttribute("Length");
|
||||
xmlAttribute.Value = resourceCode.Length.ToString();
|
||||
xmlCode.Attributes.SetNamedItem(xmlAttribute);
|
||||
xmlAttribute = xmlDocument.CreateAttribute("HashCode");
|
||||
xmlAttribute.Value = resourceCode.HashCode.ToString();
|
||||
xmlCode.Attributes.SetNamedItem(xmlAttribute);
|
||||
xmlAttribute = xmlDocument.CreateAttribute("CompressedLength");
|
||||
xmlAttribute.Value = resourceCode.CompressedLength.ToString();
|
||||
xmlCode.Attributes.SetNamedItem(xmlAttribute);
|
||||
xmlAttribute = xmlDocument.CreateAttribute("CompressedHashCode");
|
||||
xmlAttribute.Value = resourceCode.CompressedHashCode.ToString();
|
||||
xmlCode.Attributes.SetNamedItem(xmlAttribute);
|
||||
xmlCodes.AppendChild(xmlCode);
|
||||
}
|
||||
}
|
||||
|
||||
xmlDocument.Save(m_BuildReportName);
|
||||
File.WriteAllText(m_BuildLogName, m_LogBuilder.ToString());
|
||||
}
|
||||
|
||||
private void LogInternal(string type, string format, object[] args)
|
||||
{
|
||||
m_LogBuilder.AppendFormat("[{0:HH:mm:ss.fff}][{1}] ", DateTime.UtcNow.ToLocalTime(), type);
|
||||
m_LogBuilder.AppendFormat(format, args);
|
||||
m_LogBuilder.AppendLine();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ae0020ba4726cbd46b34a2341c16cd6a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using GameFramework.FileSystem;
|
||||
|
||||
namespace UnityGameFramework.Editor.ResourceTools
|
||||
{
|
||||
public sealed partial class ResourceBuilderController
|
||||
{
|
||||
private sealed class FileSystemHelper : IFileSystemHelper
|
||||
{
|
||||
public FileSystemStream CreateFileSystemStream(string fullPath, FileSystemAccess access, bool createNew)
|
||||
{
|
||||
return new CommonFileSystemStream(fullPath, access, createNew);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 23c25a2b879a092409b04f2e7851ac6b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+70
@@ -0,0 +1,70 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
namespace UnityGameFramework.Editor.ResourceTools
|
||||
{
|
||||
public sealed partial class ResourceBuilderController
|
||||
{
|
||||
private sealed class ResourceCode
|
||||
{
|
||||
private readonly Platform m_Platform;
|
||||
private readonly int m_Length;
|
||||
private readonly int m_HashCode;
|
||||
private readonly int m_CompressedLength;
|
||||
private readonly int m_CompressedHashCode;
|
||||
|
||||
public ResourceCode(Platform platform, int length, int hashCode, int compressedLength, int compressedHashCode)
|
||||
{
|
||||
m_Platform = platform;
|
||||
m_Length = length;
|
||||
m_HashCode = hashCode;
|
||||
m_CompressedLength = compressedLength;
|
||||
m_CompressedHashCode = compressedHashCode;
|
||||
}
|
||||
|
||||
public Platform Platform
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Platform;
|
||||
}
|
||||
}
|
||||
|
||||
public int Length
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Length;
|
||||
}
|
||||
}
|
||||
|
||||
public int HashCode
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_HashCode;
|
||||
}
|
||||
}
|
||||
|
||||
public int CompressedLength
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_CompressedLength;
|
||||
}
|
||||
}
|
||||
|
||||
public int CompressedHashCode
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_CompressedHashCode;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 86943b1b61e58a340b707c7c11f47700
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+167
@@ -0,0 +1,167 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace UnityGameFramework.Editor.ResourceTools
|
||||
{
|
||||
public sealed partial class ResourceBuilderController
|
||||
{
|
||||
private sealed class ResourceData
|
||||
{
|
||||
private readonly string m_Name;
|
||||
private readonly string m_Variant;
|
||||
private readonly string m_FileSystem;
|
||||
private readonly LoadType m_LoadType;
|
||||
private readonly bool m_Packed;
|
||||
private readonly string[] m_ResourceGroups;
|
||||
private readonly List<AssetData> m_AssetDatas;
|
||||
private readonly List<ResourceCode> m_Codes;
|
||||
|
||||
public ResourceData(string name, string variant, string fileSystem, LoadType loadType, bool packed, string[] resourceGroups)
|
||||
{
|
||||
m_Name = name;
|
||||
m_Variant = variant;
|
||||
m_FileSystem = fileSystem;
|
||||
m_LoadType = loadType;
|
||||
m_Packed = packed;
|
||||
m_ResourceGroups = resourceGroups;
|
||||
m_AssetDatas = new List<AssetData>();
|
||||
m_Codes = new List<ResourceCode>();
|
||||
}
|
||||
|
||||
public string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Name;
|
||||
}
|
||||
}
|
||||
|
||||
public string Variant
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Variant;
|
||||
}
|
||||
}
|
||||
|
||||
public string FileSystem
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_FileSystem;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsLoadFromBinary
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_LoadType == LoadType.LoadFromBinary || m_LoadType == LoadType.LoadFromBinaryAndQuickDecrypt || m_LoadType == LoadType.LoadFromBinaryAndDecrypt;
|
||||
}
|
||||
}
|
||||
|
||||
public LoadType LoadType
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_LoadType;
|
||||
}
|
||||
}
|
||||
|
||||
public bool Packed
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Packed;
|
||||
}
|
||||
}
|
||||
|
||||
public int AssetCount
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_AssetDatas.Count;
|
||||
}
|
||||
}
|
||||
|
||||
public string[] GetResourceGroups()
|
||||
{
|
||||
return m_ResourceGroups;
|
||||
}
|
||||
|
||||
public string[] GetAssetGuids()
|
||||
{
|
||||
string[] assetGuids = new string[m_AssetDatas.Count];
|
||||
for (int i = 0; i < m_AssetDatas.Count; i++)
|
||||
{
|
||||
assetGuids[i] = m_AssetDatas[i].Guid;
|
||||
}
|
||||
|
||||
return assetGuids;
|
||||
}
|
||||
|
||||
public string[] GetAssetNames()
|
||||
{
|
||||
string[] assetNames = new string[m_AssetDatas.Count];
|
||||
for (int i = 0; i < m_AssetDatas.Count; i++)
|
||||
{
|
||||
assetNames[i] = m_AssetDatas[i].Name;
|
||||
}
|
||||
|
||||
return assetNames;
|
||||
}
|
||||
|
||||
public AssetData[] GetAssetDatas()
|
||||
{
|
||||
return m_AssetDatas.ToArray();
|
||||
}
|
||||
|
||||
public AssetData GetAssetData(string assetName)
|
||||
{
|
||||
foreach (AssetData assetData in m_AssetDatas)
|
||||
{
|
||||
if (assetData.Name == assetName)
|
||||
{
|
||||
return assetData;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void AddAssetData(string guid, string name, int length, int hashCode, string[] dependencyAssetNames)
|
||||
{
|
||||
m_AssetDatas.Add(new AssetData(guid, name, length, hashCode, dependencyAssetNames));
|
||||
}
|
||||
|
||||
public ResourceCode GetCode(Platform platform)
|
||||
{
|
||||
foreach (ResourceCode code in m_Codes)
|
||||
{
|
||||
if (code.Platform == platform)
|
||||
{
|
||||
return code;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public ResourceCode[] GetCodes()
|
||||
{
|
||||
return m_Codes.ToArray();
|
||||
}
|
||||
|
||||
public void AddCode(Platform platform, int length, int hashCode, int compressedLength, int compressedHashCode)
|
||||
{
|
||||
m_Codes.Add(new ResourceCode(platform, length, hashCode, compressedLength, compressedHashCode));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 61757cf57a877ce46a12429a7e8996dd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
namespace UnityGameFramework.Editor.ResourceTools
|
||||
{
|
||||
public sealed partial class ResourceBuilderController
|
||||
{
|
||||
private sealed class VersionListData
|
||||
{
|
||||
public VersionListData(string path, int length, int hashCode, int compressedLength, int compressedHashCode)
|
||||
{
|
||||
Path = path;
|
||||
Length = length;
|
||||
HashCode = hashCode;
|
||||
CompressedLength = compressedLength;
|
||||
CompressedHashCode = compressedHashCode;
|
||||
}
|
||||
|
||||
public string Path
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public int Length
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public int HashCode
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public int CompressedLength
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public int CompressedHashCode
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c69cd2ac760709b4ab36ba15bc5d8759
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2678da0502f5874429b8bce3d35f573f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user