TEngine全面更新,升级YooAsset2.1.1、UniTask、UIWindow、I2Localization

TEngine全面更新,升级YooAsset2.1.1、UniTask、UIWindow、I2Localization
This commit is contained in:
ALEXTANG
2024-03-18 14:53:26 +08:00
parent 04ecf71eab
commit 6fec792e05
1015 changed files with 55183 additions and 35089 deletions

View File

@@ -4,47 +4,47 @@ using System.Collections.Generic;
namespace YooAsset.Editor
{
public class BuildContext
{
private readonly Dictionary<System.Type, IContextObject> _contextObjects = new Dictionary<System.Type, IContextObject>();
public class BuildContext
{
private readonly Dictionary<System.Type, IContextObject> _contextObjects = new Dictionary<System.Type, IContextObject>();
/// <summary>
/// 清空所有情景对象
/// </summary>
public void ClearAllContext()
{
_contextObjects.Clear();
}
/// <summary>
/// 清空所有情景对象
/// </summary>
public void ClearAllContext()
{
_contextObjects.Clear();
}
/// <summary>
/// 设置情景对象
/// </summary>
public void SetContextObject(IContextObject contextObject)
{
if (contextObject == null)
throw new ArgumentNullException("contextObject");
/// <summary>
/// 设置情景对象
/// </summary>
public void SetContextObject(IContextObject contextObject)
{
if (contextObject == null)
throw new ArgumentNullException("contextObject");
var type = contextObject.GetType();
if (_contextObjects.ContainsKey(type))
throw new Exception($"Context object {type} is already existed.");
var type = contextObject.GetType();
if (_contextObjects.ContainsKey(type))
throw new Exception($"Context object {type} is already existed.");
_contextObjects.Add(type, contextObject);
}
_contextObjects.Add(type, contextObject);
}
/// <summary>
/// 获取情景对象
/// </summary>
public T GetContextObject<T>() where T : IContextObject
{
var type = typeof(T);
if (_contextObjects.TryGetValue(type, out IContextObject contextObject))
{
return (T)contextObject;
}
else
{
throw new Exception($"Not found context object : {type}");
}
}
}
/// <summary>
/// 获取情景对象
/// </summary>
public T GetContextObject<T>() where T : IContextObject
{
var type = typeof(T);
if (_contextObjects.TryGetValue(type, out IContextObject contextObject))
{
return (T)contextObject;
}
else
{
throw new Exception($"Not found context object : {type}");
}
}
}
}

View File

@@ -5,29 +5,34 @@ using UnityEngine;
namespace YooAsset.Editor
{
public static class BuildLogger
{
private static bool _enableLog = true;
internal static class BuildLogger
{
private static bool _enableLog = true;
public static void InitLogger(bool enableLog)
{
_enableLog = enableLog;
}
public static void InitLogger(bool enableLog)
{
_enableLog = enableLog;
}
public static void Log(string message)
{
if (_enableLog)
{
Debug.Log(message);
}
}
public static void Warning(string message)
{
Debug.LogWarning(message);
}
public static void Error(string message)
{
Debug.LogError(message);
}
}
public static void Log(string message)
{
if (_enableLog)
{
Debug.Log(message);
}
}
public static void Warning(string message)
{
Debug.LogWarning(message);
}
public static void Error(string message)
{
Debug.LogError(message);
}
public static string GetErrorMessage(ErrorCode code, string message)
{
return $"[ErrorCode{(int)code}] {message}";
}
}
}

View File

@@ -7,66 +7,64 @@ using UnityEngine;
namespace YooAsset.Editor
{
public class BuildRunner
{
private static Stopwatch _buildWatch;
public class BuildRunner
{
private static Stopwatch _buildWatch;
/// <summary>
/// 总耗时
/// </summary>
public static int TotalSeconds = 0;
/// <summary>
/// 总耗时
/// </summary>
public static int TotalSeconds = 0;
/// <summary>
/// 执行构建流程
/// </summary>
/// <returns>如果成功返回TRUE否则返回FALSE</returns>
public static BuildResult Run(List<IBuildTask> pipeline, BuildContext context)
{
if (pipeline == null)
throw new ArgumentNullException("pipeline");
if (context == null)
throw new ArgumentNullException("context");
/// <summary>
/// 执行构建流程
/// </summary>
/// <returns>如果成功返回TRUE否则返回FALSE</returns>
public static BuildResult Run(List<IBuildTask> pipeline, BuildContext context)
{
if (pipeline == null)
throw new ArgumentNullException("pipeline");
if (context == null)
throw new ArgumentNullException("context");
BuildResult buildResult = new BuildResult();
buildResult.Success = true;
TotalSeconds = 0;
for (int i = 0; i < pipeline.Count; i++)
{
IBuildTask task = pipeline[i];
try
{
_buildWatch = Stopwatch.StartNew();
var taskAttribute = task.GetType().GetCustomAttribute<TaskAttribute>();
if (taskAttribute != null)
BuildLogger.Log($"---------------------------------------->{taskAttribute.TaskDesc}<---------------------------------------");
task.Run(context);
_buildWatch.Stop();
BuildResult buildResult = new BuildResult();
buildResult.Success = true;
TotalSeconds = 0;
for (int i = 0; i < pipeline.Count; i++)
{
IBuildTask task = pipeline[i];
try
{
_buildWatch = Stopwatch.StartNew();
string taskName = task.GetType().Name.Split('_')[0];
BuildLogger.Log($"--------------------------------------------->{taskName}<--------------------------------------------");
task.Run(context);
_buildWatch.Stop();
// 统计耗时
int seconds = GetBuildSeconds();
TotalSeconds += seconds;
if (taskAttribute != null)
BuildLogger.Log($"{taskAttribute.TaskDesc}耗时:{seconds}秒");
}
catch (Exception e)
{
EditorTools.ClearProgressBar();
buildResult.FailedTask = task.GetType().Name;
buildResult.ErrorInfo = e.ToString();
buildResult.Success = false;
break;
}
}
// 统计耗时
int seconds = GetBuildSeconds();
TotalSeconds += seconds;
BuildLogger.Log($"{taskName} It takes {seconds} seconds in total");
}
catch (Exception e)
{
EditorTools.ClearProgressBar();
buildResult.FailedTask = task.GetType().Name;
buildResult.ErrorInfo = e.ToString();
buildResult.Success = false;
break;
}
}
// 返回运行结果
BuildLogger.Log($"构建过程总计耗时:{TotalSeconds}");
return buildResult;
}
// 返回运行结果
BuildLogger.Log($"Total build process time: {TotalSeconds} seconds");
return buildResult;
}
private static int GetBuildSeconds()
{
float seconds = _buildWatch.ElapsedMilliseconds / 1000f;
return (int)seconds;
}
}
private static int GetBuildSeconds()
{
float seconds = _buildWatch.ElapsedMilliseconds / 1000f;
return (int)seconds;
}
}
}

View File

@@ -0,0 +1,43 @@

namespace YooAsset.Editor
{
internal enum ErrorCode
{
// TaskPrepare
ThePipelineIsBuiding = 100,
FoundUnsavedScene = 101,
NoBuildTarget = 110,
PackageNameIsNullOrEmpty = 111,
PackageVersionIsNullOrEmpty = 112,
BuildOutputRootIsNullOrEmpty = 113,
BuildinFileRootIsNullOrEmpty = 114,
PackageOutputDirectoryExists = 115,
RecommendScriptBuildPipeline = 130,
BuildPipelineNotSupportBuildMode = 140,
BuildPipelineNotSupportSharePackRule = 141,
// TaskGetBuildMap
RemoveInvalidTags = 200,
FoundUndependedAsset = 201,
PackAssetListIsEmpty = 202,
NotSupportMultipleRawAsset = 210,
// TaskBuilding
UnityEngineBuildFailed = 300,
UnityEngineBuildFatal = 301,
// TaskUpdateBundleInfo
CharactersOverTheLimit = 400,
NotFoundUnityBundleHash = 401,
NotFoundUnityBundleCRC = 402,
BundleTempSizeIsZero = 403,
// TaskVerifyBuildResult
UnintendedBuildBundle = 500,
UnintendedBuildResult = 501,
// TaskCreateManifest
NotFoundUnityBundleInBuildResult = 600,
FoundStrayBundle = 601,
}
}

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 35749e57d9a3da84aa60c348bc6bbe9d
guid: c3a10fd19801c0c428bac53081a96517
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@@ -1,7 +1,7 @@

namespace YooAsset.Editor
{
public interface IContextObject
{
}
public interface IContextObject
{
}
}

View File

@@ -1,18 +0,0 @@
using System;
namespace YooAsset.Editor
{
[AttributeUsage(AttributeTargets.Class)]
public class TaskAttribute : Attribute
{
/// <summary>
/// 任务说明
/// </summary>
public string TaskDesc;
public TaskAttribute(string taskDesc)
{
TaskDesc = taskDesc;
}
}
}