mirror of
https://github.com/Alex-Rachel/TEngine.git
synced 2025-08-14 16:51:28 +00:00
Update
This commit is contained in:
143
Assets/TEngine/Editor/Inspector/MemoryPoolComponentInspector.cs
Normal file
143
Assets/TEngine/Editor/Inspector/MemoryPoolComponentInspector.cs
Normal file
@@ -0,0 +1,143 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace TEngine.Editor.Inspector
|
||||
{
|
||||
[CustomEditor(typeof(MemoryPoolComponent))]
|
||||
internal sealed class MemoryPoolComponentInspector : GameFrameworkInspector
|
||||
{
|
||||
private readonly Dictionary<string, List<MemoryPoolInfo>> m_MemoryPoolInfos = new Dictionary<string, List<MemoryPoolInfo>>(StringComparer.Ordinal);
|
||||
private readonly HashSet<string> m_OpenedItems = new HashSet<string>();
|
||||
|
||||
private SerializedProperty m_EnableStrictCheck = null;
|
||||
|
||||
private bool m_ShowFullClassName = false;
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
base.OnInspectorGUI();
|
||||
|
||||
serializedObject.Update();
|
||||
|
||||
MemoryPoolComponent t = (MemoryPoolComponent)target;
|
||||
|
||||
if (EditorApplication.isPlaying && IsPrefabInHierarchy(t.gameObject))
|
||||
{
|
||||
bool enableStrictCheck = EditorGUILayout.Toggle("Enable Strict Check", t.EnableStrictCheck);
|
||||
if (enableStrictCheck != t.EnableStrictCheck)
|
||||
{
|
||||
t.EnableStrictCheck = enableStrictCheck;
|
||||
}
|
||||
|
||||
EditorGUILayout.LabelField("Memory Pool Count", MemoryPool.Count.ToString());
|
||||
m_ShowFullClassName = EditorGUILayout.Toggle("Show Full Class Name", m_ShowFullClassName);
|
||||
m_MemoryPoolInfos.Clear();
|
||||
MemoryPoolInfo[] memoryPoolInfos = MemoryPool.GetAllMemoryPoolInfos();
|
||||
foreach (MemoryPoolInfo memoryPoolInfo in memoryPoolInfos)
|
||||
{
|
||||
string assemblyName = memoryPoolInfo.Type.Assembly.GetName().Name;
|
||||
List<MemoryPoolInfo> results = null;
|
||||
if (!m_MemoryPoolInfos.TryGetValue(assemblyName, out results))
|
||||
{
|
||||
results = new List<MemoryPoolInfo>();
|
||||
m_MemoryPoolInfos.Add(assemblyName, results);
|
||||
}
|
||||
|
||||
results.Add(memoryPoolInfo);
|
||||
}
|
||||
|
||||
foreach (KeyValuePair<string, List<MemoryPoolInfo>> assemblyMemoryPoolInfo in m_MemoryPoolInfos)
|
||||
{
|
||||
bool lastState = m_OpenedItems.Contains(assemblyMemoryPoolInfo.Key);
|
||||
bool currentState = EditorGUILayout.Foldout(lastState, assemblyMemoryPoolInfo.Key);
|
||||
if (currentState != lastState)
|
||||
{
|
||||
if (currentState)
|
||||
{
|
||||
m_OpenedItems.Add(assemblyMemoryPoolInfo.Key);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_OpenedItems.Remove(assemblyMemoryPoolInfo.Key);
|
||||
}
|
||||
}
|
||||
|
||||
if (currentState)
|
||||
{
|
||||
EditorGUILayout.BeginVertical("box");
|
||||
{
|
||||
EditorGUILayout.LabelField(m_ShowFullClassName ? "Full Class Name" : "Class Name", "Unused\tUsing\tAcquire\tRelease\tAdd\tRemove");
|
||||
assemblyMemoryPoolInfo.Value.Sort(Comparison);
|
||||
foreach (MemoryPoolInfo memoryPoolInfo in assemblyMemoryPoolInfo.Value)
|
||||
{
|
||||
DrawMemoryPoolInfo(memoryPoolInfo);
|
||||
}
|
||||
|
||||
if (GUILayout.Button("Export CSV Data"))
|
||||
{
|
||||
string exportFileName = EditorUtility.SaveFilePanel("Export CSV Data", string.Empty, Utility.Text.Format("Memory Pool Data - {0}.csv", assemblyMemoryPoolInfo.Key), string.Empty);
|
||||
if (!string.IsNullOrEmpty(exportFileName))
|
||||
{
|
||||
try
|
||||
{
|
||||
int index = 0;
|
||||
string[] data = new string[assemblyMemoryPoolInfo.Value.Count + 1];
|
||||
data[index++] = "Class Name,Full Class Name,Unused,Using,Acquire,Release,Add,Remove";
|
||||
foreach (MemoryPoolInfo memoryPoolInfo in assemblyMemoryPoolInfo.Value)
|
||||
{
|
||||
data[index++] = Utility.Text.Format("{0},{1},{2},{3},{4},{5},{6},{7}", memoryPoolInfo.Type.Name, memoryPoolInfo.Type.FullName, memoryPoolInfo.UnusedMemoryCount.ToString(), memoryPoolInfo.UsingMemoryCount.ToString(), memoryPoolInfo.AcquireMemoryCount.ToString(), memoryPoolInfo.ReleaseMemoryCount.ToString(), memoryPoolInfo.AddMemoryCount.ToString(), memoryPoolInfo.RemoveMemoryCount.ToString());
|
||||
}
|
||||
|
||||
File.WriteAllLines(exportFileName, data, Encoding.UTF8);
|
||||
Debug.Log(Utility.Text.Format("Export memory pool CSV data to '{0}' success.", exportFileName));
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Debug.LogError(Utility.Text.Format("Export memory pool CSV data to '{0}' failure, exception is '{1}'.", exportFileName, exception.ToString()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
EditorGUILayout.EndVertical();
|
||||
|
||||
EditorGUILayout.Separator();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
EditorGUILayout.PropertyField(m_EnableStrictCheck);
|
||||
}
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
|
||||
Repaint();
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
m_EnableStrictCheck = serializedObject.FindProperty("m_EnableStrictCheck");
|
||||
}
|
||||
|
||||
private void DrawMemoryPoolInfo(MemoryPoolInfo memoryPoolInfo)
|
||||
{
|
||||
EditorGUILayout.LabelField(m_ShowFullClassName ? memoryPoolInfo.Type.FullName : memoryPoolInfo.Type.Name, Utility.Text.Format("{0}\t{1}\t{2}\t{3}\t{4}\t{5}", memoryPoolInfo.UnusedMemoryCount.ToString(), memoryPoolInfo.UsingMemoryCount.ToString(), memoryPoolInfo.AcquireMemoryCount.ToString(), memoryPoolInfo.ReleaseMemoryCount.ToString(), memoryPoolInfo.AddMemoryCount.ToString(), memoryPoolInfo.RemoveMemoryCount.ToString()));
|
||||
}
|
||||
|
||||
private int Comparison(MemoryPoolInfo a, MemoryPoolInfo b)
|
||||
{
|
||||
if (m_ShowFullClassName)
|
||||
{
|
||||
return a.Type.FullName.CompareTo(b.Type.FullName);
|
||||
}
|
||||
else
|
||||
{
|
||||
return a.Type.Name.CompareTo(b.Type.Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4c56705de5d84bd4b80ed19e50515179
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Assets/TEngine/Runtime/Exception.meta
Normal file
8
Assets/TEngine/Runtime/Exception.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b39b7b76b9ffaa240b1566ad6aae3f50
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
49
Assets/TEngine/Runtime/Exception/GameFrameworkException.cs
Normal file
49
Assets/TEngine/Runtime/Exception/GameFrameworkException.cs
Normal file
@@ -0,0 +1,49 @@
|
||||
using System;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace TEngine
|
||||
{
|
||||
/// <summary>
|
||||
/// 游戏框架异常类。
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class GameFrameworkException : Exception
|
||||
{
|
||||
/// <summary>
|
||||
/// 初始化游戏框架异常类的新实例。
|
||||
/// </summary>
|
||||
public GameFrameworkException()
|
||||
: base()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 使用指定错误消息初始化游戏框架异常类的新实例。
|
||||
/// </summary>
|
||||
/// <param name="message">描述错误的消息。</param>
|
||||
public GameFrameworkException(string message)
|
||||
: base(message)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 使用指定错误消息和对作为此异常原因的内部异常的引用来初始化游戏框架异常类的新实例。
|
||||
/// </summary>
|
||||
/// <param name="message">解释异常原因的错误消息。</param>
|
||||
/// <param name="innerException">导致当前异常的异常。如果 innerException 参数不为空引用,则在处理内部异常的 catch 块中引发当前异常。</param>
|
||||
public GameFrameworkException(string message, Exception innerException)
|
||||
: base(message, innerException)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 用序列化数据初始化游戏框架异常类的新实例。
|
||||
/// </summary>
|
||||
/// <param name="info">存有有关所引发异常的序列化的对象数据。</param>
|
||||
/// <param name="context">包含有关源或目标的上下文信息。</param>
|
||||
protected GameFrameworkException(SerializationInfo info, StreamingContext context)
|
||||
: base(info, context)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a67d24dea0e24d14899d926af7e6a9f4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Assets/TEngine/Runtime/Log.meta
Normal file
8
Assets/TEngine/Runtime/Log.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7b9564e840a9b9e4d8379d5dc781a265
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
18
Assets/TEngine/Runtime/Log/GameFrameworkLog.ILogHelper.cs
Normal file
18
Assets/TEngine/Runtime/Log/GameFrameworkLog.ILogHelper.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
namespace TEngine
|
||||
{
|
||||
public static partial class GameFrameworkLog
|
||||
{
|
||||
/// <summary>
|
||||
/// 游戏框架日志辅助器接口。
|
||||
/// </summary>
|
||||
public interface ILogHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// 记录日志。
|
||||
/// </summary>
|
||||
/// <param name="level">游戏框架日志等级。</param>
|
||||
/// <param name="message">日志内容。</param>
|
||||
void Log(GameFrameworkLogLevel level, object message);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 742233e5df6aba34098af0b7ddbda8ee
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
2639
Assets/TEngine/Runtime/Log/GameFrameworkLog.cs
Normal file
2639
Assets/TEngine/Runtime/Log/GameFrameworkLog.cs
Normal file
File diff suppressed because it is too large
Load Diff
11
Assets/TEngine/Runtime/Log/GameFrameworkLog.cs.meta
Normal file
11
Assets/TEngine/Runtime/Log/GameFrameworkLog.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 08656a09d0b681e44b7f14da94cdd3a5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
33
Assets/TEngine/Runtime/Log/GameFrameworkLogLevel.cs
Normal file
33
Assets/TEngine/Runtime/Log/GameFrameworkLogLevel.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
namespace TEngine
|
||||
{
|
||||
/// <summary>
|
||||
/// 游戏框架日志等级。
|
||||
/// </summary>
|
||||
public enum GameFrameworkLogLevel : byte
|
||||
{
|
||||
/// <summary>
|
||||
/// 调试。
|
||||
/// </summary>
|
||||
Debug = 0,
|
||||
|
||||
/// <summary>
|
||||
/// 信息。
|
||||
/// </summary>
|
||||
Info,
|
||||
|
||||
/// <summary>
|
||||
/// 警告。
|
||||
/// </summary>
|
||||
Warning,
|
||||
|
||||
/// <summary>
|
||||
/// 错误。
|
||||
/// </summary>
|
||||
Error,
|
||||
|
||||
/// <summary>
|
||||
/// 严重错误。
|
||||
/// </summary>
|
||||
Fatal
|
||||
}
|
||||
}
|
11
Assets/TEngine/Runtime/Log/GameFrameworkLogLevel.cs.meta
Normal file
11
Assets/TEngine/Runtime/Log/GameFrameworkLogLevel.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e30a51c0f37958144940a6e7fc39d661
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
193
Assets/TEngine/Runtime/Log/TEngineLogHelper.cs
Normal file
193
Assets/TEngine/Runtime/Log/TEngineLogHelper.cs
Normal file
@@ -0,0 +1,193 @@
|
||||
using System.Diagnostics;
|
||||
using System.Text;
|
||||
using Debug = UnityEngine.Debug;
|
||||
|
||||
namespace TEngine
|
||||
{
|
||||
public class TEngineLogHelper : GameFrameworkLog.ILogHelper
|
||||
{
|
||||
public void Log(GameFrameworkLogLevel level, object message)
|
||||
{
|
||||
switch (level)
|
||||
{
|
||||
case GameFrameworkLogLevel.Debug:
|
||||
TEngineLogger.LogInfo(Utility.Text.Format("<color=#888888>{0}</color>", message));
|
||||
break;
|
||||
case GameFrameworkLogLevel.Info:
|
||||
TEngineLogger.LogInfo(message.ToString());
|
||||
break;
|
||||
|
||||
case GameFrameworkLogLevel.Warning:
|
||||
TEngineLogger.LogWarning(message.ToString());
|
||||
break;
|
||||
|
||||
case GameFrameworkLogLevel.Error:
|
||||
TEngineLogger.LogError(message.ToString());
|
||||
break;
|
||||
case GameFrameworkLogLevel.Fatal:
|
||||
TEngineLogger.LogException(message.ToString());
|
||||
break;
|
||||
default:
|
||||
throw new GameFrameworkException(message.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class TEngineLogger
|
||||
{
|
||||
public static void LogInfo(string logStr)
|
||||
{
|
||||
Log(LogLevel.INFO, logStr);
|
||||
}
|
||||
|
||||
public static void LogWarning(string logStr)
|
||||
{
|
||||
Log(LogLevel.WARNING, logStr);
|
||||
}
|
||||
|
||||
public static void LogError(string logStr)
|
||||
{
|
||||
Log(LogLevel.ERROR, logStr);
|
||||
}
|
||||
|
||||
public static void LogException(string logStr)
|
||||
{
|
||||
Log(LogLevel.EXCEPTION, logStr);
|
||||
}
|
||||
|
||||
private static StringBuilder GetFormatString(LogLevel logLevel, string logString, bool bColor)
|
||||
{
|
||||
_stringBuilder.Clear();
|
||||
#if UNITY_EDITOR
|
||||
string timeNow = System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss fff");
|
||||
#else
|
||||
string timeNow = string.Empty;
|
||||
#endif
|
||||
switch (logLevel)
|
||||
{
|
||||
case LogLevel.Successd:
|
||||
_stringBuilder.AppendFormat(
|
||||
bColor
|
||||
? "<color=#0099bc><b>[TEngine] ► </b></color><color=gray><b>[INFO] ► </b></color>[{0}] - <color=#00FF18>{1}</color>"
|
||||
: "<color=#0099bc><b>[TEngine] ► </b></color><color=#00FF18><b>[SUCCESSED] ► </b></color>[{0}] - {1}",
|
||||
timeNow, logString);
|
||||
break;
|
||||
case LogLevel.INFO:
|
||||
_stringBuilder.AppendFormat(
|
||||
bColor
|
||||
? "<color=#0099bc><b>[TEngine] ► </b></color><color=gray><b>[INFO] ► </b></color>[{0}] - <color=gray>{1}</color>"
|
||||
: "<color=#0099bc><b>[TEngine] ► </b></color><color=gray><b>[INFO] ► </b></color>[{0}] - {1}",
|
||||
timeNow, logString);
|
||||
break;
|
||||
case LogLevel.ASSERT:
|
||||
_stringBuilder.AppendFormat(
|
||||
bColor
|
||||
? "<color=#0099bc><b>[TEngine] ► </b></color><color=#FF00BD><b>[ASSERT] ► </b></color>[{0}] - <color=green>{1}</color>"
|
||||
: "<color=#0099bc><b>[TEngine] ► </b></color><color=#FF00BD><b>[ASSERT] ► </b></color>[{0}] - {1}",
|
||||
timeNow, logString);
|
||||
break;
|
||||
case LogLevel.WARNING:
|
||||
_stringBuilder.AppendFormat(
|
||||
bColor
|
||||
? "<color=#0099bc><b>[TEngine] ► </b></color><color=#FF9400><b>[WARNING] ► </b></color>[{0}] - <color=yellow>{1}</color>"
|
||||
: "<color=#0099bc><b>[TEngine] ► </b></color><color=#FF9400><b>[WARNING] ► </b></color>[{0}] - {1}", timeNow,
|
||||
logString);
|
||||
break;
|
||||
case LogLevel.ERROR:
|
||||
_stringBuilder.AppendFormat(
|
||||
bColor
|
||||
? "<color=#0099bc><b>[TEngine] ► </b></color><color=red><b>[ERROR] ► </b></color>[{0}] - <color=red>{1}</color>"
|
||||
: "<color=#0099bc><b>[TEngine] ► </b></color><color=red><b>[ERROR] ► </b></color>[{0}] - {1}",
|
||||
timeNow, logString);
|
||||
break;
|
||||
case LogLevel.EXCEPTION:
|
||||
_stringBuilder.AppendFormat(
|
||||
bColor
|
||||
? "<color=#0099bc><b>[TEngine] ► </b></color><color=red><b>[EXCEPTION] ► </b></color>[{0}] - <color=red>{1}</color>"
|
||||
: "<color=#0099bc><b>[TEngine] ► </b></color><color=red><b>[EXCEPTION] ► </b></color>[{0}] - {1}",
|
||||
timeNow, logString);
|
||||
break;
|
||||
}
|
||||
|
||||
return _stringBuilder;
|
||||
}
|
||||
|
||||
private static void Log(LogLevel type, string logString)
|
||||
{
|
||||
if (_outputType == OutputType.NONE)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (type < _filterLevel)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
StringBuilder infoBuilder = GetFormatString(type, logString, true);
|
||||
string logStr = infoBuilder.ToString();
|
||||
|
||||
//获取C#堆栈,Warning以上级别日志才获取堆栈
|
||||
if (type == LogLevel.ERROR || type == LogLevel.WARNING || type == LogLevel.EXCEPTION)
|
||||
{
|
||||
StackFrame[] stackFrames = new StackTrace().GetFrames();
|
||||
for (int i = 0; i < stackFrames.Length; i++)
|
||||
{
|
||||
StackFrame frame = stackFrames[i];
|
||||
string declaringTypeName = frame.GetMethod().DeclaringType.FullName;
|
||||
string methodName = stackFrames[i].GetMethod().Name;
|
||||
|
||||
infoBuilder.AppendFormat("[{0}::{1}\n", declaringTypeName, methodName);
|
||||
}
|
||||
}
|
||||
|
||||
if (type == LogLevel.INFO || type == LogLevel.Successd)
|
||||
{
|
||||
Debug.Log(logStr);
|
||||
}
|
||||
else if (type == LogLevel.WARNING)
|
||||
{
|
||||
Debug.LogWarning(logStr);
|
||||
}
|
||||
else if (type == LogLevel.ASSERT)
|
||||
{
|
||||
Debug.LogAssertion(logStr);
|
||||
}
|
||||
else if (type == LogLevel.ERROR)
|
||||
{
|
||||
Debug.LogError(logStr);
|
||||
}
|
||||
else if (type == LogLevel.EXCEPTION)
|
||||
{
|
||||
Debug.LogError(logStr);
|
||||
}
|
||||
}
|
||||
|
||||
#region Properties
|
||||
|
||||
public enum LogLevel
|
||||
{
|
||||
INFO,
|
||||
Successd,
|
||||
ASSERT,
|
||||
WARNING,
|
||||
ERROR,
|
||||
EXCEPTION,
|
||||
}
|
||||
|
||||
[System.Flags]
|
||||
public enum OutputType
|
||||
{
|
||||
NONE = 0,
|
||||
EDITOR = 0x1,
|
||||
GUI = 0x2,
|
||||
FILE = 0x4
|
||||
}
|
||||
|
||||
private static LogLevel _filterLevel = LogLevel.INFO;
|
||||
private static OutputType _outputType = OutputType.EDITOR;
|
||||
private static StringBuilder _stringBuilder = new StringBuilder();
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
11
Assets/TEngine/Runtime/Log/TEngineLogHelper.cs.meta
Normal file
11
Assets/TEngine/Runtime/Log/TEngineLogHelper.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9d1c8c8d1b08988469817ae1e309cc37
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Assets/TEngine/Runtime/MemoryPool.meta
Normal file
8
Assets/TEngine/Runtime/MemoryPool.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e386a4a3ad14379439f1dd4d07d49a86
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
13
Assets/TEngine/Runtime/MemoryPool/IMemory.cs
Normal file
13
Assets/TEngine/Runtime/MemoryPool/IMemory.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
namespace TEngine
|
||||
{
|
||||
/// <summary>
|
||||
/// 内存对象Interface
|
||||
/// </summary>
|
||||
public interface IMemory
|
||||
{
|
||||
/// <summary>
|
||||
/// 清理内存对象回收入池
|
||||
/// </summary>
|
||||
void Clear();
|
||||
}
|
||||
}
|
11
Assets/TEngine/Runtime/MemoryPool/IMemory.cs.meta
Normal file
11
Assets/TEngine/Runtime/MemoryPool/IMemory.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 29d6300317e70b24381120ac8f5b0a92
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
198
Assets/TEngine/Runtime/MemoryPool/MemoryPool.MemoryCollection.cs
Normal file
198
Assets/TEngine/Runtime/MemoryPool/MemoryPool.MemoryCollection.cs
Normal file
@@ -0,0 +1,198 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace TEngine
|
||||
{
|
||||
public static partial class MemoryPool
|
||||
{
|
||||
/// <summary>
|
||||
/// 内存池收集器
|
||||
/// </summary>
|
||||
private sealed class MemoryCollection
|
||||
{
|
||||
private readonly Queue<IMemory> m_Memories;
|
||||
private readonly Type m_MemoryType;
|
||||
private int m_UsingMemoryCount;
|
||||
private int m_AcquireMemoryCount;
|
||||
private int m_ReleaseMemoryCount;
|
||||
private int m_AddMemoryCount;
|
||||
private int m_RemoveMemoryCount;
|
||||
|
||||
public MemoryCollection(Type memoryType)
|
||||
{
|
||||
m_Memories = new Queue<IMemory>();
|
||||
m_MemoryType = memoryType;
|
||||
m_UsingMemoryCount = 0;
|
||||
m_AcquireMemoryCount = 0;
|
||||
m_ReleaseMemoryCount = 0;
|
||||
m_AddMemoryCount = 0;
|
||||
m_RemoveMemoryCount = 0;
|
||||
}
|
||||
|
||||
public Type MemoryType
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_MemoryType;
|
||||
}
|
||||
}
|
||||
|
||||
public int UnusedMemoryCount
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Memories.Count;
|
||||
}
|
||||
}
|
||||
|
||||
public int UsingMemoryCount
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_UsingMemoryCount;
|
||||
}
|
||||
}
|
||||
|
||||
public int AcquireMemoryCount
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_AcquireMemoryCount;
|
||||
}
|
||||
}
|
||||
|
||||
public int ReleaseMemoryCount
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_ReleaseMemoryCount;
|
||||
}
|
||||
}
|
||||
|
||||
public int AddMemoryCount
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_AddMemoryCount;
|
||||
}
|
||||
}
|
||||
|
||||
public int RemoveMemoryCount
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_RemoveMemoryCount;
|
||||
}
|
||||
}
|
||||
|
||||
public T Acquire<T>() where T : class, IMemory, new()
|
||||
{
|
||||
if (typeof(T) != m_MemoryType)
|
||||
{
|
||||
throw new Exception("Type is invalid.");
|
||||
}
|
||||
|
||||
m_UsingMemoryCount++;
|
||||
m_AcquireMemoryCount++;
|
||||
lock (m_Memories)
|
||||
{
|
||||
if (m_Memories.Count > 0)
|
||||
{
|
||||
return (T)m_Memories.Dequeue();
|
||||
}
|
||||
}
|
||||
|
||||
m_AddMemoryCount++;
|
||||
return new T();
|
||||
}
|
||||
|
||||
public IMemory Acquire()
|
||||
{
|
||||
m_UsingMemoryCount++;
|
||||
m_AcquireMemoryCount++;
|
||||
lock (m_Memories)
|
||||
{
|
||||
if (m_Memories.Count > 0)
|
||||
{
|
||||
return m_Memories.Dequeue();
|
||||
}
|
||||
}
|
||||
|
||||
m_AddMemoryCount++;
|
||||
return (IMemory)Activator.CreateInstance(m_MemoryType);
|
||||
}
|
||||
|
||||
public void Release(IMemory memory)
|
||||
{
|
||||
memory.Clear();
|
||||
lock (m_Memories)
|
||||
{
|
||||
if (m_EnableStrictCheck && m_Memories.Contains(memory))
|
||||
{
|
||||
throw new Exception("The memory has been released.");
|
||||
}
|
||||
|
||||
m_Memories.Enqueue(memory);
|
||||
}
|
||||
|
||||
m_ReleaseMemoryCount++;
|
||||
m_UsingMemoryCount--;
|
||||
}
|
||||
|
||||
public void Add<T>(int count) where T : class, IMemory, new()
|
||||
{
|
||||
if (typeof(T) != m_MemoryType)
|
||||
{
|
||||
throw new Exception("Type is invalid.");
|
||||
}
|
||||
|
||||
lock (m_Memories)
|
||||
{
|
||||
m_AddMemoryCount += count;
|
||||
while (count-- > 0)
|
||||
{
|
||||
m_Memories.Enqueue(new T());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Add(int count)
|
||||
{
|
||||
lock (m_Memories)
|
||||
{
|
||||
m_AddMemoryCount += count;
|
||||
while (count-- > 0)
|
||||
{
|
||||
m_Memories.Enqueue((IMemory)Activator.CreateInstance(m_MemoryType));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Remove(int count)
|
||||
{
|
||||
lock (m_Memories)
|
||||
{
|
||||
if (count > m_Memories.Count)
|
||||
{
|
||||
count = m_Memories.Count;
|
||||
}
|
||||
|
||||
m_RemoveMemoryCount += count;
|
||||
while (count-- > 0)
|
||||
{
|
||||
m_Memories.Dequeue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void RemoveAll()
|
||||
{
|
||||
lock (m_Memories)
|
||||
{
|
||||
m_RemoveMemoryCount += m_Memories.Count;
|
||||
m_Memories.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e4ec5f33991c55f41bceefbdb8089ae2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
218
Assets/TEngine/Runtime/MemoryPool/MemoryPool.cs
Normal file
218
Assets/TEngine/Runtime/MemoryPool/MemoryPool.cs
Normal file
@@ -0,0 +1,218 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace TEngine
|
||||
{
|
||||
/// <summary>
|
||||
/// 内存池。
|
||||
/// </summary>
|
||||
public static partial class MemoryPool
|
||||
{
|
||||
private static readonly Dictionary<Type, MemoryCollection> s_MemoryCollections = new Dictionary<Type, MemoryCollection>();
|
||||
private static bool m_EnableStrictCheck = false;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置是否开启强制检查。
|
||||
/// </summary>
|
||||
public static bool EnableStrictCheck
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_EnableStrictCheck;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_EnableStrictCheck = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取内存池的数量。
|
||||
/// </summary>
|
||||
public static int Count
|
||||
{
|
||||
get
|
||||
{
|
||||
return s_MemoryCollections.Count;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取所有内存池的信息。
|
||||
/// </summary>
|
||||
/// <returns>所有内存池的信息。</returns>
|
||||
public static MemoryPoolInfo[] GetAllMemoryPoolInfos()
|
||||
{
|
||||
int index = 0;
|
||||
MemoryPoolInfo[] results = null;
|
||||
|
||||
lock (s_MemoryCollections)
|
||||
{
|
||||
results = new MemoryPoolInfo[s_MemoryCollections.Count];
|
||||
foreach (KeyValuePair<Type, MemoryCollection> memoryCollection in s_MemoryCollections)
|
||||
{
|
||||
results[index++] = new MemoryPoolInfo(memoryCollection.Key, memoryCollection.Value.UnusedMemoryCount, memoryCollection.Value.UsingMemoryCount, memoryCollection.Value.AcquireMemoryCount, memoryCollection.Value.ReleaseMemoryCount, memoryCollection.Value.AddMemoryCount, memoryCollection.Value.RemoveMemoryCount);
|
||||
}
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 清除所有内存池。
|
||||
/// </summary>
|
||||
public static void ClearAll()
|
||||
{
|
||||
lock (s_MemoryCollections)
|
||||
{
|
||||
foreach (KeyValuePair<Type, MemoryCollection> memoryCollection in s_MemoryCollections)
|
||||
{
|
||||
memoryCollection.Value.RemoveAll();
|
||||
}
|
||||
|
||||
s_MemoryCollections.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 从内存池获取内存对象。
|
||||
/// </summary>
|
||||
/// <typeparam name="T">内存对象类型。</typeparam>
|
||||
/// <returns>内存对象。</returns>
|
||||
public static T Acquire<T>() where T : class, IMemory, new()
|
||||
{
|
||||
return GetMemoryCollection(typeof(T)).Acquire<T>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 从内存池获取内存对象。
|
||||
/// </summary>
|
||||
/// <param name="memoryType">内存对象类型。</param>
|
||||
/// <returns>内存对象。</returns>
|
||||
public static IMemory Acquire(Type memoryType)
|
||||
{
|
||||
InternalCheckMemoryType(memoryType);
|
||||
return GetMemoryCollection(memoryType).Acquire();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 将内存对象归还内存池。
|
||||
/// </summary>
|
||||
/// <param name="memory">内存对象。</param>
|
||||
public static void Release(IMemory memory)
|
||||
{
|
||||
if (memory == null)
|
||||
{
|
||||
throw new Exception("Memory is invalid.");
|
||||
}
|
||||
|
||||
Type memoryType = memory.GetType();
|
||||
InternalCheckMemoryType(memoryType);
|
||||
GetMemoryCollection(memoryType).Release(memory);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 向内存池中追加指定数量的内存对象。
|
||||
/// </summary>
|
||||
/// <typeparam name="T">内存对象类型。</typeparam>
|
||||
/// <param name="count">追加数量。</param>
|
||||
public static void Add<T>(int count) where T : class, IMemory, new()
|
||||
{
|
||||
GetMemoryCollection(typeof(T)).Add<T>(count);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 向内存池中追加指定数量的内存对象。
|
||||
/// </summary>
|
||||
/// <param name="memoryType">内存对象类型。</param>
|
||||
/// <param name="count">追加数量。</param>
|
||||
public static void Add(Type memoryType, int count)
|
||||
{
|
||||
InternalCheckMemoryType(memoryType);
|
||||
GetMemoryCollection(memoryType).Add(count);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 从内存池中移除指定数量的内存对象。
|
||||
/// </summary>
|
||||
/// <typeparam name="T">内存对象类型。</typeparam>
|
||||
/// <param name="count">移除数量。</param>
|
||||
public static void Remove<T>(int count) where T : class, IMemory
|
||||
{
|
||||
GetMemoryCollection(typeof(T)).Remove(count);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 从内存池中移除指定数量的内存对象。
|
||||
/// </summary>
|
||||
/// <param name="memoryType">内存对象类型。</param>
|
||||
/// <param name="count">移除数量。</param>
|
||||
public static void Remove(Type memoryType, int count)
|
||||
{
|
||||
InternalCheckMemoryType(memoryType);
|
||||
GetMemoryCollection(memoryType).Remove(count);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 从内存池中移除所有的内存对象。
|
||||
/// </summary>
|
||||
/// <typeparam name="T">内存对象类型。</typeparam>
|
||||
public static void RemoveAll<T>() where T : class, IMemory
|
||||
{
|
||||
GetMemoryCollection(typeof(T)).RemoveAll();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 从内存池中移除所有的内存对象。
|
||||
/// </summary>
|
||||
/// <param name="memoryType">内存对象类型。</param>
|
||||
public static void RemoveAll(Type memoryType)
|
||||
{
|
||||
InternalCheckMemoryType(memoryType);
|
||||
GetMemoryCollection(memoryType).RemoveAll();
|
||||
}
|
||||
|
||||
private static void InternalCheckMemoryType(Type memoryType)
|
||||
{
|
||||
if (!m_EnableStrictCheck)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (memoryType == null)
|
||||
{
|
||||
throw new Exception("Memory type is invalid.");
|
||||
}
|
||||
|
||||
if (!memoryType.IsClass || memoryType.IsAbstract)
|
||||
{
|
||||
throw new Exception("Memory type is not a non-abstract class type.");
|
||||
}
|
||||
|
||||
if (!typeof(IMemory).IsAssignableFrom(memoryType))
|
||||
{
|
||||
throw new Exception(string.Format("Memory type '{0}' is invalid.", memoryType.FullName));
|
||||
}
|
||||
}
|
||||
|
||||
private static MemoryCollection GetMemoryCollection(Type memoryType)
|
||||
{
|
||||
if (memoryType == null)
|
||||
{
|
||||
throw new Exception("MemoryType is invalid.");
|
||||
}
|
||||
|
||||
MemoryCollection memoryCollection = null;
|
||||
lock (s_MemoryCollections)
|
||||
{
|
||||
if (!s_MemoryCollections.TryGetValue(memoryType, out memoryCollection))
|
||||
{
|
||||
memoryCollection = new MemoryCollection(memoryType);
|
||||
s_MemoryCollections.Add(memoryType, memoryCollection);
|
||||
}
|
||||
}
|
||||
|
||||
return memoryCollection;
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/TEngine/Runtime/MemoryPool/MemoryPool.cs.meta
Normal file
11
Assets/TEngine/Runtime/MemoryPool/MemoryPool.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f253bd3093bf78d45ad11b73c134e9ff
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
82
Assets/TEngine/Runtime/MemoryPool/MemoryPoolComponent.cs
Normal file
82
Assets/TEngine/Runtime/MemoryPool/MemoryPoolComponent.cs
Normal file
@@ -0,0 +1,82 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace TEngine
|
||||
{
|
||||
/// <summary>
|
||||
/// 内存强制检查类型。
|
||||
/// </summary>
|
||||
public enum MemoryStrictCheckType : byte
|
||||
{
|
||||
/// <summary>
|
||||
/// 总是启用。
|
||||
/// </summary>
|
||||
AlwaysEnable = 0,
|
||||
|
||||
/// <summary>
|
||||
/// 仅在开发模式时启用。
|
||||
/// </summary>
|
||||
OnlyEnableWhenDevelopment,
|
||||
|
||||
/// <summary>
|
||||
/// 仅在编辑器中启用。
|
||||
/// </summary>
|
||||
OnlyEnableInEditor,
|
||||
|
||||
/// <summary>
|
||||
/// 总是禁用。
|
||||
/// </summary>
|
||||
AlwaysDisable,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 基础组件。
|
||||
/// </summary>
|
||||
[DisallowMultipleComponent]
|
||||
[AddComponentMenu("TEngine/MemoryPool")]
|
||||
public sealed class MemoryPoolComponent : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
private MemoryStrictCheckType m_EnableStrictCheck = MemoryStrictCheckType.AlwaysEnable;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置是否开启强制检查。
|
||||
/// </summary>
|
||||
public bool EnableStrictCheck
|
||||
{
|
||||
get
|
||||
{
|
||||
return MemoryPool.EnableStrictCheck;
|
||||
}
|
||||
set
|
||||
{
|
||||
MemoryPool.EnableStrictCheck = value;
|
||||
if (value)
|
||||
{
|
||||
Log.Info("Strict checking is enabled for the Memory Pool. It will drastically affect the performance.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
switch (m_EnableStrictCheck)
|
||||
{
|
||||
case MemoryStrictCheckType.AlwaysEnable:
|
||||
EnableStrictCheck = true;
|
||||
break;
|
||||
|
||||
case MemoryStrictCheckType.OnlyEnableWhenDevelopment:
|
||||
EnableStrictCheck = Debug.isDebugBuild;
|
||||
break;
|
||||
|
||||
case MemoryStrictCheckType.OnlyEnableInEditor:
|
||||
EnableStrictCheck = Application.isEditor;
|
||||
break;
|
||||
|
||||
default:
|
||||
EnableStrictCheck = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 61474d279eb27214d9178822796f3b88
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
118
Assets/TEngine/Runtime/MemoryPool/MemoryPoolInfo.cs
Normal file
118
Assets/TEngine/Runtime/MemoryPool/MemoryPoolInfo.cs
Normal file
@@ -0,0 +1,118 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace TEngine
|
||||
{
|
||||
/// <summary>
|
||||
/// 内存池信息。
|
||||
/// </summary>
|
||||
[StructLayout(LayoutKind.Auto)]
|
||||
public struct MemoryPoolInfo
|
||||
{
|
||||
private readonly Type m_Type;
|
||||
private readonly int m_UnusedMemoryCount;
|
||||
private readonly int m_UsingMemoryCount;
|
||||
private readonly int m_AcquireMemoryCount;
|
||||
private readonly int m_ReleaseMemoryCount;
|
||||
private readonly int m_AddMemoryCount;
|
||||
private readonly int m_RemoveMemoryCount;
|
||||
|
||||
/// <summary>
|
||||
/// 初始化内存池信息的新实例。
|
||||
/// </summary>
|
||||
/// <param name="type">内存池类型。</param>
|
||||
/// <param name="unusedMemoryCount">未使用内存对象数量。</param>
|
||||
/// <param name="usingMemoryCount">正在使用内存对象数量。</param>
|
||||
/// <param name="acquireMemoryCount">获取内存对象数量。</param>
|
||||
/// <param name="releaseMemoryCount">归还内存对象数量。</param>
|
||||
/// <param name="addMemoryCount">增加内存对象数量。</param>
|
||||
/// <param name="removeMemoryCount">移除内存对象数量。</param>
|
||||
public MemoryPoolInfo(Type type, int unusedMemoryCount, int usingMemoryCount, int acquireMemoryCount, int releaseMemoryCount, int addMemoryCount, int removeMemoryCount)
|
||||
{
|
||||
m_Type = type;
|
||||
m_UnusedMemoryCount = unusedMemoryCount;
|
||||
m_UsingMemoryCount = usingMemoryCount;
|
||||
m_AcquireMemoryCount = acquireMemoryCount;
|
||||
m_ReleaseMemoryCount = releaseMemoryCount;
|
||||
m_AddMemoryCount = addMemoryCount;
|
||||
m_RemoveMemoryCount = removeMemoryCount;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取内存池类型。
|
||||
/// </summary>
|
||||
public Type Type
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Type;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取未使用内存对象数量。
|
||||
/// </summary>
|
||||
public int UnusedMemoryCount
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_UnusedMemoryCount;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取正在使用内存对象数量。
|
||||
/// </summary>
|
||||
public int UsingMemoryCount
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_UsingMemoryCount;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取获取内存对象数量。
|
||||
/// </summary>
|
||||
public int AcquireMemoryCount
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_AcquireMemoryCount;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取归还内存对象数量。
|
||||
/// </summary>
|
||||
public int ReleaseMemoryCount
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_ReleaseMemoryCount;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取增加内存对象数量。
|
||||
/// </summary>
|
||||
public int AddMemoryCount
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_AddMemoryCount;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取移除内存对象数量。
|
||||
/// </summary>
|
||||
public int RemoveMemoryCount
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_RemoveMemoryCount;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/TEngine/Runtime/MemoryPool/MemoryPoolInfo.cs.meta
Normal file
11
Assets/TEngine/Runtime/MemoryPool/MemoryPoolInfo.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 444aa83c59c8f0445894e785975b5463
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Assets/TEngine/Runtime/Utility.meta
Normal file
8
Assets/TEngine/Runtime/Utility.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4768a00bcf9cf9d4197da234b968867c
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
2749
Assets/TEngine/Runtime/Utility/Log.cs
Normal file
2749
Assets/TEngine/Runtime/Utility/Log.cs
Normal file
File diff suppressed because it is too large
Load Diff
11
Assets/TEngine/Runtime/Utility/Log.cs.meta
Normal file
11
Assets/TEngine/Runtime/Utility/Log.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1e9d579404484cb40b5049f1307a6139
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
398
Assets/TEngine/Runtime/Utility/Utility.Text.ITextHelper.cs
Normal file
398
Assets/TEngine/Runtime/Utility/Utility.Text.ITextHelper.cs
Normal file
@@ -0,0 +1,398 @@
|
||||
namespace TEngine
|
||||
{
|
||||
public static partial class Utility
|
||||
{
|
||||
public static partial class Text
|
||||
{
|
||||
/// <summary>
|
||||
/// 字符辅助器接口。
|
||||
/// </summary>
|
||||
public interface ITextHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取格式化字符串。
|
||||
/// </summary>
|
||||
/// <typeparam name="T">字符串参数的类型。</typeparam>
|
||||
/// <param name="format">字符串格式。</param>
|
||||
/// <param name="arg">字符串参数。</param>
|
||||
/// <returns>格式化后的字符串。</returns>
|
||||
string Format<T>(string format, T arg);
|
||||
|
||||
/// <summary>
|
||||
/// 获取格式化字符串。
|
||||
/// </summary>
|
||||
/// <typeparam name="T1">字符串参数 1 的类型。</typeparam>
|
||||
/// <typeparam name="T2">字符串参数 2 的类型。</typeparam>
|
||||
/// <param name="format">字符串格式。</param>
|
||||
/// <param name="arg1">字符串参数 1。</param>
|
||||
/// <param name="arg2">字符串参数 2。</param>
|
||||
/// <returns>格式化后的字符串。</returns>
|
||||
string Format<T1, T2>(string format, T1 arg1, T2 arg2);
|
||||
|
||||
/// <summary>
|
||||
/// 获取格式化字符串。
|
||||
/// </summary>
|
||||
/// <typeparam name="T1">字符串参数 1 的类型。</typeparam>
|
||||
/// <typeparam name="T2">字符串参数 2 的类型。</typeparam>
|
||||
/// <typeparam name="T3">字符串参数 3 的类型。</typeparam>
|
||||
/// <param name="format">字符串格式。</param>
|
||||
/// <param name="arg1">字符串参数 1。</param>
|
||||
/// <param name="arg2">字符串参数 2。</param>
|
||||
/// <param name="arg3">字符串参数 3。</param>
|
||||
/// <returns>格式化后的字符串。</returns>
|
||||
string Format<T1, T2, T3>(string format, T1 arg1, T2 arg2, T3 arg3);
|
||||
|
||||
/// <summary>
|
||||
/// 获取格式化字符串。
|
||||
/// </summary>
|
||||
/// <typeparam name="T1">字符串参数 1 的类型。</typeparam>
|
||||
/// <typeparam name="T2">字符串参数 2 的类型。</typeparam>
|
||||
/// <typeparam name="T3">字符串参数 3 的类型。</typeparam>
|
||||
/// <typeparam name="T4">字符串参数 4 的类型。</typeparam>
|
||||
/// <param name="format">字符串格式。</param>
|
||||
/// <param name="arg1">字符串参数 1。</param>
|
||||
/// <param name="arg2">字符串参数 2。</param>
|
||||
/// <param name="arg3">字符串参数 3。</param>
|
||||
/// <param name="arg4">字符串参数 4。</param>
|
||||
/// <returns>格式化后的字符串。</returns>
|
||||
string Format<T1, T2, T3, T4>(string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4);
|
||||
|
||||
/// <summary>
|
||||
/// 获取格式化字符串。
|
||||
/// </summary>
|
||||
/// <typeparam name="T1">字符串参数 1 的类型。</typeparam>
|
||||
/// <typeparam name="T2">字符串参数 2 的类型。</typeparam>
|
||||
/// <typeparam name="T3">字符串参数 3 的类型。</typeparam>
|
||||
/// <typeparam name="T4">字符串参数 4 的类型。</typeparam>
|
||||
/// <typeparam name="T5">字符串参数 5 的类型。</typeparam>
|
||||
/// <param name="format">字符串格式。</param>
|
||||
/// <param name="arg1">字符串参数 1。</param>
|
||||
/// <param name="arg2">字符串参数 2。</param>
|
||||
/// <param name="arg3">字符串参数 3。</param>
|
||||
/// <param name="arg4">字符串参数 4。</param>
|
||||
/// <param name="arg5">字符串参数 5。</param>
|
||||
/// <returns>格式化后的字符串。</returns>
|
||||
string Format<T1, T2, T3, T4, T5>(string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5);
|
||||
|
||||
/// <summary>
|
||||
/// 获取格式化字符串。
|
||||
/// </summary>
|
||||
/// <typeparam name="T1">字符串参数 1 的类型。</typeparam>
|
||||
/// <typeparam name="T2">字符串参数 2 的类型。</typeparam>
|
||||
/// <typeparam name="T3">字符串参数 3 的类型。</typeparam>
|
||||
/// <typeparam name="T4">字符串参数 4 的类型。</typeparam>
|
||||
/// <typeparam name="T5">字符串参数 5 的类型。</typeparam>
|
||||
/// <typeparam name="T6">字符串参数 6 的类型。</typeparam>
|
||||
/// <param name="format">字符串格式。</param>
|
||||
/// <param name="arg1">字符串参数 1。</param>
|
||||
/// <param name="arg2">字符串参数 2。</param>
|
||||
/// <param name="arg3">字符串参数 3。</param>
|
||||
/// <param name="arg4">字符串参数 4。</param>
|
||||
/// <param name="arg5">字符串参数 5。</param>
|
||||
/// <param name="arg6">字符串参数 6。</param>
|
||||
/// <returns>格式化后的字符串。</returns>
|
||||
string Format<T1, T2, T3, T4, T5, T6>(string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6);
|
||||
|
||||
/// <summary>
|
||||
/// 获取格式化字符串。
|
||||
/// </summary>
|
||||
/// <typeparam name="T1">字符串参数 1 的类型。</typeparam>
|
||||
/// <typeparam name="T2">字符串参数 2 的类型。</typeparam>
|
||||
/// <typeparam name="T3">字符串参数 3 的类型。</typeparam>
|
||||
/// <typeparam name="T4">字符串参数 4 的类型。</typeparam>
|
||||
/// <typeparam name="T5">字符串参数 5 的类型。</typeparam>
|
||||
/// <typeparam name="T6">字符串参数 6 的类型。</typeparam>
|
||||
/// <typeparam name="T7">字符串参数 7 的类型。</typeparam>
|
||||
/// <param name="format">字符串格式。</param>
|
||||
/// <param name="arg1">字符串参数 1。</param>
|
||||
/// <param name="arg2">字符串参数 2。</param>
|
||||
/// <param name="arg3">字符串参数 3。</param>
|
||||
/// <param name="arg4">字符串参数 4。</param>
|
||||
/// <param name="arg5">字符串参数 5。</param>
|
||||
/// <param name="arg6">字符串参数 6。</param>
|
||||
/// <param name="arg7">字符串参数 7。</param>
|
||||
/// <returns>格式化后的字符串。</returns>
|
||||
string Format<T1, T2, T3, T4, T5, T6, T7>(string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7);
|
||||
|
||||
/// <summary>
|
||||
/// 获取格式化字符串。
|
||||
/// </summary>
|
||||
/// <typeparam name="T1">字符串参数 1 的类型。</typeparam>
|
||||
/// <typeparam name="T2">字符串参数 2 的类型。</typeparam>
|
||||
/// <typeparam name="T3">字符串参数 3 的类型。</typeparam>
|
||||
/// <typeparam name="T4">字符串参数 4 的类型。</typeparam>
|
||||
/// <typeparam name="T5">字符串参数 5 的类型。</typeparam>
|
||||
/// <typeparam name="T6">字符串参数 6 的类型。</typeparam>
|
||||
/// <typeparam name="T7">字符串参数 7 的类型。</typeparam>
|
||||
/// <typeparam name="T8">字符串参数 8 的类型。</typeparam>
|
||||
/// <param name="format">字符串格式。</param>
|
||||
/// <param name="arg1">字符串参数 1。</param>
|
||||
/// <param name="arg2">字符串参数 2。</param>
|
||||
/// <param name="arg3">字符串参数 3。</param>
|
||||
/// <param name="arg4">字符串参数 4。</param>
|
||||
/// <param name="arg5">字符串参数 5。</param>
|
||||
/// <param name="arg6">字符串参数 6。</param>
|
||||
/// <param name="arg7">字符串参数 7。</param>
|
||||
/// <param name="arg8">字符串参数 8。</param>
|
||||
/// <returns>格式化后的字符串。</returns>
|
||||
string Format<T1, T2, T3, T4, T5, T6, T7, T8>(string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8);
|
||||
|
||||
/// <summary>
|
||||
/// 获取格式化字符串。
|
||||
/// </summary>
|
||||
/// <typeparam name="T1">字符串参数 1 的类型。</typeparam>
|
||||
/// <typeparam name="T2">字符串参数 2 的类型。</typeparam>
|
||||
/// <typeparam name="T3">字符串参数 3 的类型。</typeparam>
|
||||
/// <typeparam name="T4">字符串参数 4 的类型。</typeparam>
|
||||
/// <typeparam name="T5">字符串参数 5 的类型。</typeparam>
|
||||
/// <typeparam name="T6">字符串参数 6 的类型。</typeparam>
|
||||
/// <typeparam name="T7">字符串参数 7 的类型。</typeparam>
|
||||
/// <typeparam name="T8">字符串参数 8 的类型。</typeparam>
|
||||
/// <typeparam name="T9">字符串参数 9 的类型。</typeparam>
|
||||
/// <param name="format">字符串格式。</param>
|
||||
/// <param name="arg1">字符串参数 1。</param>
|
||||
/// <param name="arg2">字符串参数 2。</param>
|
||||
/// <param name="arg3">字符串参数 3。</param>
|
||||
/// <param name="arg4">字符串参数 4。</param>
|
||||
/// <param name="arg5">字符串参数 5。</param>
|
||||
/// <param name="arg6">字符串参数 6。</param>
|
||||
/// <param name="arg7">字符串参数 7。</param>
|
||||
/// <param name="arg8">字符串参数 8。</param>
|
||||
/// <param name="arg9">字符串参数 9。</param>
|
||||
/// <returns>格式化后的字符串。</returns>
|
||||
string Format<T1, T2, T3, T4, T5, T6, T7, T8, T9>(string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9);
|
||||
|
||||
/// <summary>
|
||||
/// 获取格式化字符串。
|
||||
/// </summary>
|
||||
/// <typeparam name="T1">字符串参数 1 的类型。</typeparam>
|
||||
/// <typeparam name="T2">字符串参数 2 的类型。</typeparam>
|
||||
/// <typeparam name="T3">字符串参数 3 的类型。</typeparam>
|
||||
/// <typeparam name="T4">字符串参数 4 的类型。</typeparam>
|
||||
/// <typeparam name="T5">字符串参数 5 的类型。</typeparam>
|
||||
/// <typeparam name="T6">字符串参数 6 的类型。</typeparam>
|
||||
/// <typeparam name="T7">字符串参数 7 的类型。</typeparam>
|
||||
/// <typeparam name="T8">字符串参数 8 的类型。</typeparam>
|
||||
/// <typeparam name="T9">字符串参数 9 的类型。</typeparam>
|
||||
/// <typeparam name="T10">字符串参数 10 的类型。</typeparam>
|
||||
/// <param name="format">字符串格式。</param>
|
||||
/// <param name="arg1">字符串参数 1。</param>
|
||||
/// <param name="arg2">字符串参数 2。</param>
|
||||
/// <param name="arg3">字符串参数 3。</param>
|
||||
/// <param name="arg4">字符串参数 4。</param>
|
||||
/// <param name="arg5">字符串参数 5。</param>
|
||||
/// <param name="arg6">字符串参数 6。</param>
|
||||
/// <param name="arg7">字符串参数 7。</param>
|
||||
/// <param name="arg8">字符串参数 8。</param>
|
||||
/// <param name="arg9">字符串参数 9。</param>
|
||||
/// <param name="arg10">字符串参数 10。</param>
|
||||
/// <returns>格式化后的字符串。</returns>
|
||||
string Format<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10);
|
||||
|
||||
/// <summary>
|
||||
/// 获取格式化字符串。
|
||||
/// </summary>
|
||||
/// <typeparam name="T1">字符串参数 1 的类型。</typeparam>
|
||||
/// <typeparam name="T2">字符串参数 2 的类型。</typeparam>
|
||||
/// <typeparam name="T3">字符串参数 3 的类型。</typeparam>
|
||||
/// <typeparam name="T4">字符串参数 4 的类型。</typeparam>
|
||||
/// <typeparam name="T5">字符串参数 5 的类型。</typeparam>
|
||||
/// <typeparam name="T6">字符串参数 6 的类型。</typeparam>
|
||||
/// <typeparam name="T7">字符串参数 7 的类型。</typeparam>
|
||||
/// <typeparam name="T8">字符串参数 8 的类型。</typeparam>
|
||||
/// <typeparam name="T9">字符串参数 9 的类型。</typeparam>
|
||||
/// <typeparam name="T10">字符串参数 10 的类型。</typeparam>
|
||||
/// <typeparam name="T11">字符串参数 11 的类型。</typeparam>
|
||||
/// <param name="format">字符串格式。</param>
|
||||
/// <param name="arg1">字符串参数 1。</param>
|
||||
/// <param name="arg2">字符串参数 2。</param>
|
||||
/// <param name="arg3">字符串参数 3。</param>
|
||||
/// <param name="arg4">字符串参数 4。</param>
|
||||
/// <param name="arg5">字符串参数 5。</param>
|
||||
/// <param name="arg6">字符串参数 6。</param>
|
||||
/// <param name="arg7">字符串参数 7。</param>
|
||||
/// <param name="arg8">字符串参数 8。</param>
|
||||
/// <param name="arg9">字符串参数 9。</param>
|
||||
/// <param name="arg10">字符串参数 10。</param>
|
||||
/// <param name="arg11">字符串参数 11。</param>
|
||||
/// <returns>格式化后的字符串。</returns>
|
||||
string Format<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>(string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10, T11 arg11);
|
||||
|
||||
/// <summary>
|
||||
/// 获取格式化字符串。
|
||||
/// </summary>
|
||||
/// <typeparam name="T1">字符串参数 1 的类型。</typeparam>
|
||||
/// <typeparam name="T2">字符串参数 2 的类型。</typeparam>
|
||||
/// <typeparam name="T3">字符串参数 3 的类型。</typeparam>
|
||||
/// <typeparam name="T4">字符串参数 4 的类型。</typeparam>
|
||||
/// <typeparam name="T5">字符串参数 5 的类型。</typeparam>
|
||||
/// <typeparam name="T6">字符串参数 6 的类型。</typeparam>
|
||||
/// <typeparam name="T7">字符串参数 7 的类型。</typeparam>
|
||||
/// <typeparam name="T8">字符串参数 8 的类型。</typeparam>
|
||||
/// <typeparam name="T9">字符串参数 9 的类型。</typeparam>
|
||||
/// <typeparam name="T10">字符串参数 10 的类型。</typeparam>
|
||||
/// <typeparam name="T11">字符串参数 11 的类型。</typeparam>
|
||||
/// <typeparam name="T12">字符串参数 12 的类型。</typeparam>
|
||||
/// <param name="format">字符串格式。</param>
|
||||
/// <param name="arg1">字符串参数 1。</param>
|
||||
/// <param name="arg2">字符串参数 2。</param>
|
||||
/// <param name="arg3">字符串参数 3。</param>
|
||||
/// <param name="arg4">字符串参数 4。</param>
|
||||
/// <param name="arg5">字符串参数 5。</param>
|
||||
/// <param name="arg6">字符串参数 6。</param>
|
||||
/// <param name="arg7">字符串参数 7。</param>
|
||||
/// <param name="arg8">字符串参数 8。</param>
|
||||
/// <param name="arg9">字符串参数 9。</param>
|
||||
/// <param name="arg10">字符串参数 10。</param>
|
||||
/// <param name="arg11">字符串参数 11。</param>
|
||||
/// <param name="arg12">字符串参数 12。</param>
|
||||
/// <returns>格式化后的字符串。</returns>
|
||||
string Format<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10, T11 arg11, T12 arg12);
|
||||
|
||||
/// <summary>
|
||||
/// 获取格式化字符串。
|
||||
/// </summary>
|
||||
/// <typeparam name="T1">字符串参数 1 的类型。</typeparam>
|
||||
/// <typeparam name="T2">字符串参数 2 的类型。</typeparam>
|
||||
/// <typeparam name="T3">字符串参数 3 的类型。</typeparam>
|
||||
/// <typeparam name="T4">字符串参数 4 的类型。</typeparam>
|
||||
/// <typeparam name="T5">字符串参数 5 的类型。</typeparam>
|
||||
/// <typeparam name="T6">字符串参数 6 的类型。</typeparam>
|
||||
/// <typeparam name="T7">字符串参数 7 的类型。</typeparam>
|
||||
/// <typeparam name="T8">字符串参数 8 的类型。</typeparam>
|
||||
/// <typeparam name="T9">字符串参数 9 的类型。</typeparam>
|
||||
/// <typeparam name="T10">字符串参数 10 的类型。</typeparam>
|
||||
/// <typeparam name="T11">字符串参数 11 的类型。</typeparam>
|
||||
/// <typeparam name="T12">字符串参数 12 的类型。</typeparam>
|
||||
/// <typeparam name="T13">字符串参数 13 的类型。</typeparam>
|
||||
/// <param name="format">字符串格式。</param>
|
||||
/// <param name="arg1">字符串参数 1。</param>
|
||||
/// <param name="arg2">字符串参数 2。</param>
|
||||
/// <param name="arg3">字符串参数 3。</param>
|
||||
/// <param name="arg4">字符串参数 4。</param>
|
||||
/// <param name="arg5">字符串参数 5。</param>
|
||||
/// <param name="arg6">字符串参数 6。</param>
|
||||
/// <param name="arg7">字符串参数 7。</param>
|
||||
/// <param name="arg8">字符串参数 8。</param>
|
||||
/// <param name="arg9">字符串参数 9。</param>
|
||||
/// <param name="arg10">字符串参数 10。</param>
|
||||
/// <param name="arg11">字符串参数 11。</param>
|
||||
/// <param name="arg12">字符串参数 12。</param>
|
||||
/// <param name="arg13">字符串参数 13。</param>
|
||||
/// <returns>格式化后的字符串。</returns>
|
||||
string Format<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>(string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10, T11 arg11, T12 arg12, T13 arg13);
|
||||
|
||||
/// <summary>
|
||||
/// 获取格式化字符串。
|
||||
/// </summary>
|
||||
/// <typeparam name="T1">字符串参数 1 的类型。</typeparam>
|
||||
/// <typeparam name="T2">字符串参数 2 的类型。</typeparam>
|
||||
/// <typeparam name="T3">字符串参数 3 的类型。</typeparam>
|
||||
/// <typeparam name="T4">字符串参数 4 的类型。</typeparam>
|
||||
/// <typeparam name="T5">字符串参数 5 的类型。</typeparam>
|
||||
/// <typeparam name="T6">字符串参数 6 的类型。</typeparam>
|
||||
/// <typeparam name="T7">字符串参数 7 的类型。</typeparam>
|
||||
/// <typeparam name="T8">字符串参数 8 的类型。</typeparam>
|
||||
/// <typeparam name="T9">字符串参数 9 的类型。</typeparam>
|
||||
/// <typeparam name="T10">字符串参数 10 的类型。</typeparam>
|
||||
/// <typeparam name="T11">字符串参数 11 的类型。</typeparam>
|
||||
/// <typeparam name="T12">字符串参数 12 的类型。</typeparam>
|
||||
/// <typeparam name="T13">字符串参数 13 的类型。</typeparam>
|
||||
/// <typeparam name="T14">字符串参数 14 的类型。</typeparam>
|
||||
/// <param name="format">字符串格式。</param>
|
||||
/// <param name="arg1">字符串参数 1。</param>
|
||||
/// <param name="arg2">字符串参数 2。</param>
|
||||
/// <param name="arg3">字符串参数 3。</param>
|
||||
/// <param name="arg4">字符串参数 4。</param>
|
||||
/// <param name="arg5">字符串参数 5。</param>
|
||||
/// <param name="arg6">字符串参数 6。</param>
|
||||
/// <param name="arg7">字符串参数 7。</param>
|
||||
/// <param name="arg8">字符串参数 8。</param>
|
||||
/// <param name="arg9">字符串参数 9。</param>
|
||||
/// <param name="arg10">字符串参数 10。</param>
|
||||
/// <param name="arg11">字符串参数 11。</param>
|
||||
/// <param name="arg12">字符串参数 12。</param>
|
||||
/// <param name="arg13">字符串参数 13。</param>
|
||||
/// <param name="arg14">字符串参数 14。</param>
|
||||
/// <returns>格式化后的字符串。</returns>
|
||||
string Format<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>(string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10, T11 arg11, T12 arg12, T13 arg13, T14 arg14);
|
||||
|
||||
/// <summary>
|
||||
/// 获取格式化字符串。
|
||||
/// </summary>
|
||||
/// <typeparam name="T1">字符串参数 1 的类型。</typeparam>
|
||||
/// <typeparam name="T2">字符串参数 2 的类型。</typeparam>
|
||||
/// <typeparam name="T3">字符串参数 3 的类型。</typeparam>
|
||||
/// <typeparam name="T4">字符串参数 4 的类型。</typeparam>
|
||||
/// <typeparam name="T5">字符串参数 5 的类型。</typeparam>
|
||||
/// <typeparam name="T6">字符串参数 6 的类型。</typeparam>
|
||||
/// <typeparam name="T7">字符串参数 7 的类型。</typeparam>
|
||||
/// <typeparam name="T8">字符串参数 8 的类型。</typeparam>
|
||||
/// <typeparam name="T9">字符串参数 9 的类型。</typeparam>
|
||||
/// <typeparam name="T10">字符串参数 10 的类型。</typeparam>
|
||||
/// <typeparam name="T11">字符串参数 11 的类型。</typeparam>
|
||||
/// <typeparam name="T12">字符串参数 12 的类型。</typeparam>
|
||||
/// <typeparam name="T13">字符串参数 13 的类型。</typeparam>
|
||||
/// <typeparam name="T14">字符串参数 14 的类型。</typeparam>
|
||||
/// <typeparam name="T15">字符串参数 15 的类型。</typeparam>
|
||||
/// <param name="format">字符串格式。</param>
|
||||
/// <param name="arg1">字符串参数 1。</param>
|
||||
/// <param name="arg2">字符串参数 2。</param>
|
||||
/// <param name="arg3">字符串参数 3。</param>
|
||||
/// <param name="arg4">字符串参数 4。</param>
|
||||
/// <param name="arg5">字符串参数 5。</param>
|
||||
/// <param name="arg6">字符串参数 6。</param>
|
||||
/// <param name="arg7">字符串参数 7。</param>
|
||||
/// <param name="arg8">字符串参数 8。</param>
|
||||
/// <param name="arg9">字符串参数 9。</param>
|
||||
/// <param name="arg10">字符串参数 10。</param>
|
||||
/// <param name="arg11">字符串参数 11。</param>
|
||||
/// <param name="arg12">字符串参数 12。</param>
|
||||
/// <param name="arg13">字符串参数 13。</param>
|
||||
/// <param name="arg14">字符串参数 14。</param>
|
||||
/// <param name="arg15">字符串参数 15。</param>
|
||||
/// <returns>格式化后的字符串。</returns>
|
||||
string Format<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>(string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10, T11 arg11, T12 arg12, T13 arg13, T14 arg14, T15 arg15);
|
||||
|
||||
/// <summary>
|
||||
/// 获取格式化字符串。
|
||||
/// </summary>
|
||||
/// <typeparam name="T1">字符串参数 1 的类型。</typeparam>
|
||||
/// <typeparam name="T2">字符串参数 2 的类型。</typeparam>
|
||||
/// <typeparam name="T3">字符串参数 3 的类型。</typeparam>
|
||||
/// <typeparam name="T4">字符串参数 4 的类型。</typeparam>
|
||||
/// <typeparam name="T5">字符串参数 5 的类型。</typeparam>
|
||||
/// <typeparam name="T6">字符串参数 6 的类型。</typeparam>
|
||||
/// <typeparam name="T7">字符串参数 7 的类型。</typeparam>
|
||||
/// <typeparam name="T8">字符串参数 8 的类型。</typeparam>
|
||||
/// <typeparam name="T9">字符串参数 9 的类型。</typeparam>
|
||||
/// <typeparam name="T10">字符串参数 10 的类型。</typeparam>
|
||||
/// <typeparam name="T11">字符串参数 11 的类型。</typeparam>
|
||||
/// <typeparam name="T12">字符串参数 12 的类型。</typeparam>
|
||||
/// <typeparam name="T13">字符串参数 13 的类型。</typeparam>
|
||||
/// <typeparam name="T14">字符串参数 14 的类型。</typeparam>
|
||||
/// <typeparam name="T15">字符串参数 15 的类型。</typeparam>
|
||||
/// <typeparam name="T16">字符串参数 16 的类型。</typeparam>
|
||||
/// <param name="format">字符串格式。</param>
|
||||
/// <param name="arg1">字符串参数 1。</param>
|
||||
/// <param name="arg2">字符串参数 2。</param>
|
||||
/// <param name="arg3">字符串参数 3。</param>
|
||||
/// <param name="arg4">字符串参数 4。</param>
|
||||
/// <param name="arg5">字符串参数 5。</param>
|
||||
/// <param name="arg6">字符串参数 6。</param>
|
||||
/// <param name="arg7">字符串参数 7。</param>
|
||||
/// <param name="arg8">字符串参数 8。</param>
|
||||
/// <param name="arg9">字符串参数 9。</param>
|
||||
/// <param name="arg10">字符串参数 10。</param>
|
||||
/// <param name="arg11">字符串参数 11。</param>
|
||||
/// <param name="arg12">字符串参数 12。</param>
|
||||
/// <param name="arg13">字符串参数 13。</param>
|
||||
/// <param name="arg14">字符串参数 14。</param>
|
||||
/// <param name="arg15">字符串参数 15。</param>
|
||||
/// <param name="arg16">字符串参数 16。</param>
|
||||
/// <returns>格式化后的字符串。</returns>
|
||||
string Format<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>(string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10, T11 arg11, T12 arg12, T13 arg13, T14 arg14, T15 arg15, T16 arg16);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 44d3c9b6114ed4a4b86fcad5a54aaace
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
614
Assets/TEngine/Runtime/Utility/Utility.Text.cs
Normal file
614
Assets/TEngine/Runtime/Utility/Utility.Text.cs
Normal file
@@ -0,0 +1,614 @@
|
||||
namespace TEngine
|
||||
{
|
||||
public static partial class Utility
|
||||
{
|
||||
/// <summary>
|
||||
/// 字符相关的实用函数。
|
||||
/// </summary>
|
||||
public static partial class Text
|
||||
{
|
||||
private static ITextHelper s_TextHelper = null;
|
||||
|
||||
/// <summary>
|
||||
/// 设置字符辅助器。
|
||||
/// </summary>
|
||||
/// <param name="textHelper">要设置的字符辅助器。</param>
|
||||
public static void SetTextHelper(ITextHelper textHelper)
|
||||
{
|
||||
s_TextHelper = textHelper;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取格式化字符串。
|
||||
/// </summary>
|
||||
/// <typeparam name="T">字符串参数的类型。</typeparam>
|
||||
/// <param name="format">字符串格式。</param>
|
||||
/// <param name="arg">字符串参数。</param>
|
||||
/// <returns>格式化后的字符串。</returns>
|
||||
public static string Format<T>(string format, T arg)
|
||||
{
|
||||
if (format == null)
|
||||
{
|
||||
throw new GameFrameworkException("Format is invalid.");
|
||||
}
|
||||
|
||||
if (s_TextHelper == null)
|
||||
{
|
||||
return string.Format(format, arg);
|
||||
}
|
||||
|
||||
return s_TextHelper.Format(format, arg);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取格式化字符串。
|
||||
/// </summary>
|
||||
/// <typeparam name="T1">字符串参数 1 的类型。</typeparam>
|
||||
/// <typeparam name="T2">字符串参数 2 的类型。</typeparam>
|
||||
/// <param name="format">字符串格式。</param>
|
||||
/// <param name="arg1">字符串参数 1。</param>
|
||||
/// <param name="arg2">字符串参数 2。</param>
|
||||
/// <returns>格式化后的字符串。</returns>
|
||||
public static string Format<T1, T2>(string format, T1 arg1, T2 arg2)
|
||||
{
|
||||
if (format == null)
|
||||
{
|
||||
throw new GameFrameworkException("Format is invalid.");
|
||||
}
|
||||
|
||||
if (s_TextHelper == null)
|
||||
{
|
||||
return string.Format(format, arg1, arg2);
|
||||
}
|
||||
|
||||
return s_TextHelper.Format(format, arg1, arg2);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取格式化字符串。
|
||||
/// </summary>
|
||||
/// <typeparam name="T1">字符串参数 1 的类型。</typeparam>
|
||||
/// <typeparam name="T2">字符串参数 2 的类型。</typeparam>
|
||||
/// <typeparam name="T3">字符串参数 3 的类型。</typeparam>
|
||||
/// <param name="format">字符串格式。</param>
|
||||
/// <param name="arg1">字符串参数 1。</param>
|
||||
/// <param name="arg2">字符串参数 2。</param>
|
||||
/// <param name="arg3">字符串参数 3。</param>
|
||||
/// <returns>格式化后的字符串。</returns>
|
||||
public static string Format<T1, T2, T3>(string format, T1 arg1, T2 arg2, T3 arg3)
|
||||
{
|
||||
if (format == null)
|
||||
{
|
||||
throw new GameFrameworkException("Format is invalid.");
|
||||
}
|
||||
|
||||
if (s_TextHelper == null)
|
||||
{
|
||||
return string.Format(format, arg1, arg2, arg3);
|
||||
}
|
||||
|
||||
return s_TextHelper.Format(format, arg1, arg2, arg3);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取格式化字符串。
|
||||
/// </summary>
|
||||
/// <typeparam name="T1">字符串参数 1 的类型。</typeparam>
|
||||
/// <typeparam name="T2">字符串参数 2 的类型。</typeparam>
|
||||
/// <typeparam name="T3">字符串参数 3 的类型。</typeparam>
|
||||
/// <typeparam name="T4">字符串参数 4 的类型。</typeparam>
|
||||
/// <param name="format">字符串格式。</param>
|
||||
/// <param name="arg1">字符串参数 1。</param>
|
||||
/// <param name="arg2">字符串参数 2。</param>
|
||||
/// <param name="arg3">字符串参数 3。</param>
|
||||
/// <param name="arg4">字符串参数 4。</param>
|
||||
/// <returns>格式化后的字符串。</returns>
|
||||
public static string Format<T1, T2, T3, T4>(string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4)
|
||||
{
|
||||
if (format == null)
|
||||
{
|
||||
throw new GameFrameworkException("Format is invalid.");
|
||||
}
|
||||
|
||||
if (s_TextHelper == null)
|
||||
{
|
||||
return string.Format(format, arg1, arg2, arg3, arg4);
|
||||
}
|
||||
|
||||
return s_TextHelper.Format(format, arg1, arg2, arg3, arg4);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取格式化字符串。
|
||||
/// </summary>
|
||||
/// <typeparam name="T1">字符串参数 1 的类型。</typeparam>
|
||||
/// <typeparam name="T2">字符串参数 2 的类型。</typeparam>
|
||||
/// <typeparam name="T3">字符串参数 3 的类型。</typeparam>
|
||||
/// <typeparam name="T4">字符串参数 4 的类型。</typeparam>
|
||||
/// <typeparam name="T5">字符串参数 5 的类型。</typeparam>
|
||||
/// <param name="format">字符串格式。</param>
|
||||
/// <param name="arg1">字符串参数 1。</param>
|
||||
/// <param name="arg2">字符串参数 2。</param>
|
||||
/// <param name="arg3">字符串参数 3。</param>
|
||||
/// <param name="arg4">字符串参数 4。</param>
|
||||
/// <param name="arg5">字符串参数 5。</param>
|
||||
/// <returns>格式化后的字符串。</returns>
|
||||
public static string Format<T1, T2, T3, T4, T5>(string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5)
|
||||
{
|
||||
if (format == null)
|
||||
{
|
||||
throw new GameFrameworkException("Format is invalid.");
|
||||
}
|
||||
|
||||
if (s_TextHelper == null)
|
||||
{
|
||||
return string.Format(format, arg1, arg2, arg3, arg4, arg5);
|
||||
}
|
||||
|
||||
return s_TextHelper.Format(format, arg1, arg2, arg3, arg4, arg5);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取格式化字符串。
|
||||
/// </summary>
|
||||
/// <typeparam name="T1">字符串参数 1 的类型。</typeparam>
|
||||
/// <typeparam name="T2">字符串参数 2 的类型。</typeparam>
|
||||
/// <typeparam name="T3">字符串参数 3 的类型。</typeparam>
|
||||
/// <typeparam name="T4">字符串参数 4 的类型。</typeparam>
|
||||
/// <typeparam name="T5">字符串参数 5 的类型。</typeparam>
|
||||
/// <typeparam name="T6">字符串参数 6 的类型。</typeparam>
|
||||
/// <param name="format">字符串格式。</param>
|
||||
/// <param name="arg1">字符串参数 1。</param>
|
||||
/// <param name="arg2">字符串参数 2。</param>
|
||||
/// <param name="arg3">字符串参数 3。</param>
|
||||
/// <param name="arg4">字符串参数 4。</param>
|
||||
/// <param name="arg5">字符串参数 5。</param>
|
||||
/// <param name="arg6">字符串参数 6。</param>
|
||||
/// <returns>格式化后的字符串。</returns>
|
||||
public static string Format<T1, T2, T3, T4, T5, T6>(string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6)
|
||||
{
|
||||
if (format == null)
|
||||
{
|
||||
throw new GameFrameworkException("Format is invalid.");
|
||||
}
|
||||
|
||||
if (s_TextHelper == null)
|
||||
{
|
||||
return string.Format(format, arg1, arg2, arg3, arg4, arg5, arg6);
|
||||
}
|
||||
|
||||
return s_TextHelper.Format(format, arg1, arg2, arg3, arg4, arg5, arg6);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取格式化字符串。
|
||||
/// </summary>
|
||||
/// <typeparam name="T1">字符串参数 1 的类型。</typeparam>
|
||||
/// <typeparam name="T2">字符串参数 2 的类型。</typeparam>
|
||||
/// <typeparam name="T3">字符串参数 3 的类型。</typeparam>
|
||||
/// <typeparam name="T4">字符串参数 4 的类型。</typeparam>
|
||||
/// <typeparam name="T5">字符串参数 5 的类型。</typeparam>
|
||||
/// <typeparam name="T6">字符串参数 6 的类型。</typeparam>
|
||||
/// <typeparam name="T7">字符串参数 7 的类型。</typeparam>
|
||||
/// <param name="format">字符串格式。</param>
|
||||
/// <param name="arg1">字符串参数 1。</param>
|
||||
/// <param name="arg2">字符串参数 2。</param>
|
||||
/// <param name="arg3">字符串参数 3。</param>
|
||||
/// <param name="arg4">字符串参数 4。</param>
|
||||
/// <param name="arg5">字符串参数 5。</param>
|
||||
/// <param name="arg6">字符串参数 6。</param>
|
||||
/// <param name="arg7">字符串参数 7。</param>
|
||||
/// <returns>格式化后的字符串。</returns>
|
||||
public static string Format<T1, T2, T3, T4, T5, T6, T7>(string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7)
|
||||
{
|
||||
if (format == null)
|
||||
{
|
||||
throw new GameFrameworkException("Format is invalid.");
|
||||
}
|
||||
|
||||
if (s_TextHelper == null)
|
||||
{
|
||||
return string.Format(format, arg1, arg2, arg3, arg4, arg5, arg6, arg7);
|
||||
}
|
||||
|
||||
return s_TextHelper.Format(format, arg1, arg2, arg3, arg4, arg5, arg6, arg7);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取格式化字符串。
|
||||
/// </summary>
|
||||
/// <typeparam name="T1">字符串参数 1 的类型。</typeparam>
|
||||
/// <typeparam name="T2">字符串参数 2 的类型。</typeparam>
|
||||
/// <typeparam name="T3">字符串参数 3 的类型。</typeparam>
|
||||
/// <typeparam name="T4">字符串参数 4 的类型。</typeparam>
|
||||
/// <typeparam name="T5">字符串参数 5 的类型。</typeparam>
|
||||
/// <typeparam name="T6">字符串参数 6 的类型。</typeparam>
|
||||
/// <typeparam name="T7">字符串参数 7 的类型。</typeparam>
|
||||
/// <typeparam name="T8">字符串参数 8 的类型。</typeparam>
|
||||
/// <param name="format">字符串格式。</param>
|
||||
/// <param name="arg1">字符串参数 1。</param>
|
||||
/// <param name="arg2">字符串参数 2。</param>
|
||||
/// <param name="arg3">字符串参数 3。</param>
|
||||
/// <param name="arg4">字符串参数 4。</param>
|
||||
/// <param name="arg5">字符串参数 5。</param>
|
||||
/// <param name="arg6">字符串参数 6。</param>
|
||||
/// <param name="arg7">字符串参数 7。</param>
|
||||
/// <param name="arg8">字符串参数 8。</param>
|
||||
/// <returns>格式化后的字符串。</returns>
|
||||
public static string Format<T1, T2, T3, T4, T5, T6, T7, T8>(string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8)
|
||||
{
|
||||
if (format == null)
|
||||
{
|
||||
throw new GameFrameworkException("Format is invalid.");
|
||||
}
|
||||
|
||||
if (s_TextHelper == null)
|
||||
{
|
||||
return string.Format(format, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8);
|
||||
}
|
||||
|
||||
return s_TextHelper.Format(format, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取格式化字符串。
|
||||
/// </summary>
|
||||
/// <typeparam name="T1">字符串参数 1 的类型。</typeparam>
|
||||
/// <typeparam name="T2">字符串参数 2 的类型。</typeparam>
|
||||
/// <typeparam name="T3">字符串参数 3 的类型。</typeparam>
|
||||
/// <typeparam name="T4">字符串参数 4 的类型。</typeparam>
|
||||
/// <typeparam name="T5">字符串参数 5 的类型。</typeparam>
|
||||
/// <typeparam name="T6">字符串参数 6 的类型。</typeparam>
|
||||
/// <typeparam name="T7">字符串参数 7 的类型。</typeparam>
|
||||
/// <typeparam name="T8">字符串参数 8 的类型。</typeparam>
|
||||
/// <typeparam name="T9">字符串参数 9 的类型。</typeparam>
|
||||
/// <param name="format">字符串格式。</param>
|
||||
/// <param name="arg1">字符串参数 1。</param>
|
||||
/// <param name="arg2">字符串参数 2。</param>
|
||||
/// <param name="arg3">字符串参数 3。</param>
|
||||
/// <param name="arg4">字符串参数 4。</param>
|
||||
/// <param name="arg5">字符串参数 5。</param>
|
||||
/// <param name="arg6">字符串参数 6。</param>
|
||||
/// <param name="arg7">字符串参数 7。</param>
|
||||
/// <param name="arg8">字符串参数 8。</param>
|
||||
/// <param name="arg9">字符串参数 9。</param>
|
||||
/// <returns>格式化后的字符串。</returns>
|
||||
public static string Format<T1, T2, T3, T4, T5, T6, T7, T8, T9>(string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9)
|
||||
{
|
||||
if (format == null)
|
||||
{
|
||||
throw new GameFrameworkException("Format is invalid.");
|
||||
}
|
||||
|
||||
if (s_TextHelper == null)
|
||||
{
|
||||
return string.Format(format, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9);
|
||||
}
|
||||
|
||||
return s_TextHelper.Format(format, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取格式化字符串。
|
||||
/// </summary>
|
||||
/// <typeparam name="T1">字符串参数 1 的类型。</typeparam>
|
||||
/// <typeparam name="T2">字符串参数 2 的类型。</typeparam>
|
||||
/// <typeparam name="T3">字符串参数 3 的类型。</typeparam>
|
||||
/// <typeparam name="T4">字符串参数 4 的类型。</typeparam>
|
||||
/// <typeparam name="T5">字符串参数 5 的类型。</typeparam>
|
||||
/// <typeparam name="T6">字符串参数 6 的类型。</typeparam>
|
||||
/// <typeparam name="T7">字符串参数 7 的类型。</typeparam>
|
||||
/// <typeparam name="T8">字符串参数 8 的类型。</typeparam>
|
||||
/// <typeparam name="T9">字符串参数 9 的类型。</typeparam>
|
||||
/// <typeparam name="T10">字符串参数 10 的类型。</typeparam>
|
||||
/// <param name="format">字符串格式。</param>
|
||||
/// <param name="arg1">字符串参数 1。</param>
|
||||
/// <param name="arg2">字符串参数 2。</param>
|
||||
/// <param name="arg3">字符串参数 3。</param>
|
||||
/// <param name="arg4">字符串参数 4。</param>
|
||||
/// <param name="arg5">字符串参数 5。</param>
|
||||
/// <param name="arg6">字符串参数 6。</param>
|
||||
/// <param name="arg7">字符串参数 7。</param>
|
||||
/// <param name="arg8">字符串参数 8。</param>
|
||||
/// <param name="arg9">字符串参数 9。</param>
|
||||
/// <param name="arg10">字符串参数 10。</param>
|
||||
/// <returns>格式化后的字符串。</returns>
|
||||
public static string Format<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10)
|
||||
{
|
||||
if (format == null)
|
||||
{
|
||||
throw new GameFrameworkException("Format is invalid.");
|
||||
}
|
||||
|
||||
if (s_TextHelper == null)
|
||||
{
|
||||
return string.Format(format, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10);
|
||||
}
|
||||
|
||||
return s_TextHelper.Format(format, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取格式化字符串。
|
||||
/// </summary>
|
||||
/// <typeparam name="T1">字符串参数 1 的类型。</typeparam>
|
||||
/// <typeparam name="T2">字符串参数 2 的类型。</typeparam>
|
||||
/// <typeparam name="T3">字符串参数 3 的类型。</typeparam>
|
||||
/// <typeparam name="T4">字符串参数 4 的类型。</typeparam>
|
||||
/// <typeparam name="T5">字符串参数 5 的类型。</typeparam>
|
||||
/// <typeparam name="T6">字符串参数 6 的类型。</typeparam>
|
||||
/// <typeparam name="T7">字符串参数 7 的类型。</typeparam>
|
||||
/// <typeparam name="T8">字符串参数 8 的类型。</typeparam>
|
||||
/// <typeparam name="T9">字符串参数 9 的类型。</typeparam>
|
||||
/// <typeparam name="T10">字符串参数 10 的类型。</typeparam>
|
||||
/// <typeparam name="T11">字符串参数 11 的类型。</typeparam>
|
||||
/// <param name="format">字符串格式。</param>
|
||||
/// <param name="arg1">字符串参数 1。</param>
|
||||
/// <param name="arg2">字符串参数 2。</param>
|
||||
/// <param name="arg3">字符串参数 3。</param>
|
||||
/// <param name="arg4">字符串参数 4。</param>
|
||||
/// <param name="arg5">字符串参数 5。</param>
|
||||
/// <param name="arg6">字符串参数 6。</param>
|
||||
/// <param name="arg7">字符串参数 7。</param>
|
||||
/// <param name="arg8">字符串参数 8。</param>
|
||||
/// <param name="arg9">字符串参数 9。</param>
|
||||
/// <param name="arg10">字符串参数 10。</param>
|
||||
/// <param name="arg11">字符串参数 11。</param>
|
||||
/// <returns>格式化后的字符串。</returns>
|
||||
public static string Format<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>(string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10, T11 arg11)
|
||||
{
|
||||
if (format == null)
|
||||
{
|
||||
throw new GameFrameworkException("Format is invalid.");
|
||||
}
|
||||
|
||||
if (s_TextHelper == null)
|
||||
{
|
||||
return string.Format(format, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11);
|
||||
}
|
||||
|
||||
return s_TextHelper.Format(format, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取格式化字符串。
|
||||
/// </summary>
|
||||
/// <typeparam name="T1">字符串参数 1 的类型。</typeparam>
|
||||
/// <typeparam name="T2">字符串参数 2 的类型。</typeparam>
|
||||
/// <typeparam name="T3">字符串参数 3 的类型。</typeparam>
|
||||
/// <typeparam name="T4">字符串参数 4 的类型。</typeparam>
|
||||
/// <typeparam name="T5">字符串参数 5 的类型。</typeparam>
|
||||
/// <typeparam name="T6">字符串参数 6 的类型。</typeparam>
|
||||
/// <typeparam name="T7">字符串参数 7 的类型。</typeparam>
|
||||
/// <typeparam name="T8">字符串参数 8 的类型。</typeparam>
|
||||
/// <typeparam name="T9">字符串参数 9 的类型。</typeparam>
|
||||
/// <typeparam name="T10">字符串参数 10 的类型。</typeparam>
|
||||
/// <typeparam name="T11">字符串参数 11 的类型。</typeparam>
|
||||
/// <typeparam name="T12">字符串参数 12 的类型。</typeparam>
|
||||
/// <param name="format">字符串格式。</param>
|
||||
/// <param name="arg1">字符串参数 1。</param>
|
||||
/// <param name="arg2">字符串参数 2。</param>
|
||||
/// <param name="arg3">字符串参数 3。</param>
|
||||
/// <param name="arg4">字符串参数 4。</param>
|
||||
/// <param name="arg5">字符串参数 5。</param>
|
||||
/// <param name="arg6">字符串参数 6。</param>
|
||||
/// <param name="arg7">字符串参数 7。</param>
|
||||
/// <param name="arg8">字符串参数 8。</param>
|
||||
/// <param name="arg9">字符串参数 9。</param>
|
||||
/// <param name="arg10">字符串参数 10。</param>
|
||||
/// <param name="arg11">字符串参数 11。</param>
|
||||
/// <param name="arg12">字符串参数 12。</param>
|
||||
/// <returns>格式化后的字符串。</returns>
|
||||
public static string Format<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10, T11 arg11, T12 arg12)
|
||||
{
|
||||
if (format == null)
|
||||
{
|
||||
throw new GameFrameworkException("Format is invalid.");
|
||||
}
|
||||
|
||||
if (s_TextHelper == null)
|
||||
{
|
||||
return string.Format(format, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12);
|
||||
}
|
||||
|
||||
return s_TextHelper.Format(format, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取格式化字符串。
|
||||
/// </summary>
|
||||
/// <typeparam name="T1">字符串参数 1 的类型。</typeparam>
|
||||
/// <typeparam name="T2">字符串参数 2 的类型。</typeparam>
|
||||
/// <typeparam name="T3">字符串参数 3 的类型。</typeparam>
|
||||
/// <typeparam name="T4">字符串参数 4 的类型。</typeparam>
|
||||
/// <typeparam name="T5">字符串参数 5 的类型。</typeparam>
|
||||
/// <typeparam name="T6">字符串参数 6 的类型。</typeparam>
|
||||
/// <typeparam name="T7">字符串参数 7 的类型。</typeparam>
|
||||
/// <typeparam name="T8">字符串参数 8 的类型。</typeparam>
|
||||
/// <typeparam name="T9">字符串参数 9 的类型。</typeparam>
|
||||
/// <typeparam name="T10">字符串参数 10 的类型。</typeparam>
|
||||
/// <typeparam name="T11">字符串参数 11 的类型。</typeparam>
|
||||
/// <typeparam name="T12">字符串参数 12 的类型。</typeparam>
|
||||
/// <typeparam name="T13">字符串参数 13 的类型。</typeparam>
|
||||
/// <param name="format">字符串格式。</param>
|
||||
/// <param name="arg1">字符串参数 1。</param>
|
||||
/// <param name="arg2">字符串参数 2。</param>
|
||||
/// <param name="arg3">字符串参数 3。</param>
|
||||
/// <param name="arg4">字符串参数 4。</param>
|
||||
/// <param name="arg5">字符串参数 5。</param>
|
||||
/// <param name="arg6">字符串参数 6。</param>
|
||||
/// <param name="arg7">字符串参数 7。</param>
|
||||
/// <param name="arg8">字符串参数 8。</param>
|
||||
/// <param name="arg9">字符串参数 9。</param>
|
||||
/// <param name="arg10">字符串参数 10。</param>
|
||||
/// <param name="arg11">字符串参数 11。</param>
|
||||
/// <param name="arg12">字符串参数 12。</param>
|
||||
/// <param name="arg13">字符串参数 13。</param>
|
||||
/// <returns>格式化后的字符串。</returns>
|
||||
public static string Format<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>(string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10, T11 arg11, T12 arg12, T13 arg13)
|
||||
{
|
||||
if (format == null)
|
||||
{
|
||||
throw new GameFrameworkException("Format is invalid.");
|
||||
}
|
||||
|
||||
if (s_TextHelper == null)
|
||||
{
|
||||
return string.Format(format, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13);
|
||||
}
|
||||
|
||||
return s_TextHelper.Format(format, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取格式化字符串。
|
||||
/// </summary>
|
||||
/// <typeparam name="T1">字符串参数 1 的类型。</typeparam>
|
||||
/// <typeparam name="T2">字符串参数 2 的类型。</typeparam>
|
||||
/// <typeparam name="T3">字符串参数 3 的类型。</typeparam>
|
||||
/// <typeparam name="T4">字符串参数 4 的类型。</typeparam>
|
||||
/// <typeparam name="T5">字符串参数 5 的类型。</typeparam>
|
||||
/// <typeparam name="T6">字符串参数 6 的类型。</typeparam>
|
||||
/// <typeparam name="T7">字符串参数 7 的类型。</typeparam>
|
||||
/// <typeparam name="T8">字符串参数 8 的类型。</typeparam>
|
||||
/// <typeparam name="T9">字符串参数 9 的类型。</typeparam>
|
||||
/// <typeparam name="T10">字符串参数 10 的类型。</typeparam>
|
||||
/// <typeparam name="T11">字符串参数 11 的类型。</typeparam>
|
||||
/// <typeparam name="T12">字符串参数 12 的类型。</typeparam>
|
||||
/// <typeparam name="T13">字符串参数 13 的类型。</typeparam>
|
||||
/// <typeparam name="T14">字符串参数 14 的类型。</typeparam>
|
||||
/// <param name="format">字符串格式。</param>
|
||||
/// <param name="arg1">字符串参数 1。</param>
|
||||
/// <param name="arg2">字符串参数 2。</param>
|
||||
/// <param name="arg3">字符串参数 3。</param>
|
||||
/// <param name="arg4">字符串参数 4。</param>
|
||||
/// <param name="arg5">字符串参数 5。</param>
|
||||
/// <param name="arg6">字符串参数 6。</param>
|
||||
/// <param name="arg7">字符串参数 7。</param>
|
||||
/// <param name="arg8">字符串参数 8。</param>
|
||||
/// <param name="arg9">字符串参数 9。</param>
|
||||
/// <param name="arg10">字符串参数 10。</param>
|
||||
/// <param name="arg11">字符串参数 11。</param>
|
||||
/// <param name="arg12">字符串参数 12。</param>
|
||||
/// <param name="arg13">字符串参数 13。</param>
|
||||
/// <param name="arg14">字符串参数 14。</param>
|
||||
/// <returns>格式化后的字符串。</returns>
|
||||
public static string Format<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>(string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10, T11 arg11, T12 arg12, T13 arg13, T14 arg14)
|
||||
{
|
||||
if (format == null)
|
||||
{
|
||||
throw new GameFrameworkException("Format is invalid.");
|
||||
}
|
||||
|
||||
if (s_TextHelper == null)
|
||||
{
|
||||
return string.Format(format, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14);
|
||||
}
|
||||
|
||||
return s_TextHelper.Format(format, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取格式化字符串。
|
||||
/// </summary>
|
||||
/// <typeparam name="T1">字符串参数 1 的类型。</typeparam>
|
||||
/// <typeparam name="T2">字符串参数 2 的类型。</typeparam>
|
||||
/// <typeparam name="T3">字符串参数 3 的类型。</typeparam>
|
||||
/// <typeparam name="T4">字符串参数 4 的类型。</typeparam>
|
||||
/// <typeparam name="T5">字符串参数 5 的类型。</typeparam>
|
||||
/// <typeparam name="T6">字符串参数 6 的类型。</typeparam>
|
||||
/// <typeparam name="T7">字符串参数 7 的类型。</typeparam>
|
||||
/// <typeparam name="T8">字符串参数 8 的类型。</typeparam>
|
||||
/// <typeparam name="T9">字符串参数 9 的类型。</typeparam>
|
||||
/// <typeparam name="T10">字符串参数 10 的类型。</typeparam>
|
||||
/// <typeparam name="T11">字符串参数 11 的类型。</typeparam>
|
||||
/// <typeparam name="T12">字符串参数 12 的类型。</typeparam>
|
||||
/// <typeparam name="T13">字符串参数 13 的类型。</typeparam>
|
||||
/// <typeparam name="T14">字符串参数 14 的类型。</typeparam>
|
||||
/// <typeparam name="T15">字符串参数 15 的类型。</typeparam>
|
||||
/// <param name="format">字符串格式。</param>
|
||||
/// <param name="arg1">字符串参数 1。</param>
|
||||
/// <param name="arg2">字符串参数 2。</param>
|
||||
/// <param name="arg3">字符串参数 3。</param>
|
||||
/// <param name="arg4">字符串参数 4。</param>
|
||||
/// <param name="arg5">字符串参数 5。</param>
|
||||
/// <param name="arg6">字符串参数 6。</param>
|
||||
/// <param name="arg7">字符串参数 7。</param>
|
||||
/// <param name="arg8">字符串参数 8。</param>
|
||||
/// <param name="arg9">字符串参数 9。</param>
|
||||
/// <param name="arg10">字符串参数 10。</param>
|
||||
/// <param name="arg11">字符串参数 11。</param>
|
||||
/// <param name="arg12">字符串参数 12。</param>
|
||||
/// <param name="arg13">字符串参数 13。</param>
|
||||
/// <param name="arg14">字符串参数 14。</param>
|
||||
/// <param name="arg15">字符串参数 15。</param>
|
||||
/// <returns>格式化后的字符串。</returns>
|
||||
public static string Format<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>(string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10, T11 arg11, T12 arg12, T13 arg13, T14 arg14, T15 arg15)
|
||||
{
|
||||
if (format == null)
|
||||
{
|
||||
throw new GameFrameworkException("Format is invalid.");
|
||||
}
|
||||
|
||||
if (s_TextHelper == null)
|
||||
{
|
||||
return string.Format(format, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15);
|
||||
}
|
||||
|
||||
return s_TextHelper.Format(format, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取格式化字符串。
|
||||
/// </summary>
|
||||
/// <typeparam name="T1">字符串参数 1 的类型。</typeparam>
|
||||
/// <typeparam name="T2">字符串参数 2 的类型。</typeparam>
|
||||
/// <typeparam name="T3">字符串参数 3 的类型。</typeparam>
|
||||
/// <typeparam name="T4">字符串参数 4 的类型。</typeparam>
|
||||
/// <typeparam name="T5">字符串参数 5 的类型。</typeparam>
|
||||
/// <typeparam name="T6">字符串参数 6 的类型。</typeparam>
|
||||
/// <typeparam name="T7">字符串参数 7 的类型。</typeparam>
|
||||
/// <typeparam name="T8">字符串参数 8 的类型。</typeparam>
|
||||
/// <typeparam name="T9">字符串参数 9 的类型。</typeparam>
|
||||
/// <typeparam name="T10">字符串参数 10 的类型。</typeparam>
|
||||
/// <typeparam name="T11">字符串参数 11 的类型。</typeparam>
|
||||
/// <typeparam name="T12">字符串参数 12 的类型。</typeparam>
|
||||
/// <typeparam name="T13">字符串参数 13 的类型。</typeparam>
|
||||
/// <typeparam name="T14">字符串参数 14 的类型。</typeparam>
|
||||
/// <typeparam name="T15">字符串参数 15 的类型。</typeparam>
|
||||
/// <typeparam name="T16">字符串参数 16 的类型。</typeparam>
|
||||
/// <param name="format">字符串格式。</param>
|
||||
/// <param name="arg1">字符串参数 1。</param>
|
||||
/// <param name="arg2">字符串参数 2。</param>
|
||||
/// <param name="arg3">字符串参数 3。</param>
|
||||
/// <param name="arg4">字符串参数 4。</param>
|
||||
/// <param name="arg5">字符串参数 5。</param>
|
||||
/// <param name="arg6">字符串参数 6。</param>
|
||||
/// <param name="arg7">字符串参数 7。</param>
|
||||
/// <param name="arg8">字符串参数 8。</param>
|
||||
/// <param name="arg9">字符串参数 9。</param>
|
||||
/// <param name="arg10">字符串参数 10。</param>
|
||||
/// <param name="arg11">字符串参数 11。</param>
|
||||
/// <param name="arg12">字符串参数 12。</param>
|
||||
/// <param name="arg13">字符串参数 13。</param>
|
||||
/// <param name="arg14">字符串参数 14。</param>
|
||||
/// <param name="arg15">字符串参数 15。</param>
|
||||
/// <param name="arg16">字符串参数 16。</param>
|
||||
/// <returns>格式化后的字符串。</returns>
|
||||
public static string Format<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>(string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10, T11 arg11, T12 arg12, T13 arg13, T14 arg14, T15 arg15, T16 arg16)
|
||||
{
|
||||
if (format == null)
|
||||
{
|
||||
throw new GameFrameworkException("Format is invalid.");
|
||||
}
|
||||
|
||||
if (s_TextHelper == null)
|
||||
{
|
||||
return string.Format(format, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15, arg16);
|
||||
}
|
||||
|
||||
return s_TextHelper.Format(format, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15, arg16);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/TEngine/Runtime/Utility/Utility.Text.cs.meta
Normal file
11
Assets/TEngine/Runtime/Utility/Utility.Text.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 803084b3a6abd88419c78ab0065dd727
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
9
Assets/TEngine/Runtime/Utility/Utility.cs
Normal file
9
Assets/TEngine/Runtime/Utility/Utility.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
namespace TEngine
|
||||
{
|
||||
/// <summary>
|
||||
/// 实用函数集。
|
||||
/// </summary>
|
||||
public static partial class Utility
|
||||
{
|
||||
}
|
||||
}
|
11
Assets/TEngine/Runtime/Utility/Utility.cs.meta
Normal file
11
Assets/TEngine/Runtime/Utility/Utility.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8fef804bcade42644b580696fad49076
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user