mirror of https://github.com/tuyoogame/YooAsset
parent
c196cd84d3
commit
2ab045658b
|
@ -199,9 +199,7 @@ namespace YooAsset.Editor
|
||||||
}
|
}
|
||||||
private List<Type> GetEncryptionServicesClassTypes()
|
private List<Type> GetEncryptionServicesClassTypes()
|
||||||
{
|
{
|
||||||
TypeCache.TypeCollection collection = TypeCache.GetTypesDerivedFrom<IEncryptionServices>();
|
return EditorTools.GetAssignableTypes(typeof(IEncryptionServices));
|
||||||
List<Type> classTypes = collection.ToList();
|
|
||||||
return classTypes;
|
|
||||||
}
|
}
|
||||||
private IEncryptionServices CreateEncryptionServicesInstance()
|
private IEncryptionServices CreateEncryptionServicesInstance()
|
||||||
{
|
{
|
||||||
|
|
|
@ -139,8 +139,7 @@ namespace YooAsset.Editor
|
||||||
typeof(PackRawFile),
|
typeof(PackRawFile),
|
||||||
};
|
};
|
||||||
|
|
||||||
TypeCache.TypeCollection collection = TypeCache.GetTypesDerivedFrom<IPackRule>();
|
var customTypes = EditorTools.GetAssignableTypes(typeof(IPackRule));
|
||||||
var customTypes = collection.ToList();
|
|
||||||
types.AddRange(customTypes);
|
types.AddRange(customTypes);
|
||||||
for (int i = 0; i < types.Count; i++)
|
for (int i = 0; i < types.Count; i++)
|
||||||
{
|
{
|
||||||
|
@ -165,8 +164,7 @@ namespace YooAsset.Editor
|
||||||
typeof(CollectSprite)
|
typeof(CollectSprite)
|
||||||
};
|
};
|
||||||
|
|
||||||
TypeCache.TypeCollection collection = TypeCache.GetTypesDerivedFrom<IFilterRule>();
|
var customTypes = EditorTools.GetAssignableTypes(typeof(IFilterRule));
|
||||||
var customTypes = collection.ToList();
|
|
||||||
types.AddRange(customTypes);
|
types.AddRange(customTypes);
|
||||||
for (int i = 0; i < types.Count; i++)
|
for (int i = 0; i < types.Count; i++)
|
||||||
{
|
{
|
||||||
|
@ -190,8 +188,7 @@ namespace YooAsset.Editor
|
||||||
typeof(AddressByGroupAndFileName)
|
typeof(AddressByGroupAndFileName)
|
||||||
};
|
};
|
||||||
|
|
||||||
TypeCache.TypeCollection collection = TypeCache.GetTypesDerivedFrom<IAddressRule>();
|
var customTypes = EditorTools.GetAssignableTypes(typeof(IAddressRule));
|
||||||
var customTypes = collection.ToList();
|
|
||||||
types.AddRange(customTypes);
|
types.AddRange(customTypes);
|
||||||
for (int i = 0; i < types.Count; i++)
|
for (int i = 0; i < types.Count; i++)
|
||||||
{
|
{
|
||||||
|
|
|
@ -4,10 +4,12 @@ namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
public class EditorDefine
|
public class EditorDefine
|
||||||
{
|
{
|
||||||
|
#if UNITY_2019_4_OR_NEWER
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 停靠窗口类型集合
|
/// 停靠窗口类型集合
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static readonly Type[] DockedWindowTypes = { typeof(AssetBundleBuilderWindow), typeof(AssetBundleCollectorWindow), typeof(AssetBundleDebuggerWindow), typeof(AssetBundleReporterWindow)};
|
public static readonly Type[] DockedWindowTypes = { typeof(AssetBundleBuilderWindow), typeof(AssetBundleCollectorWindow), typeof(AssetBundleDebuggerWindow), typeof(AssetBundleReporterWindow)};
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
using System.Collections;
|
using System;
|
||||||
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Text.RegularExpressions;
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
|
|
||||||
|
@ -15,7 +15,57 @@ namespace YooAsset.Editor
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static class EditorTools
|
public static class EditorTools
|
||||||
{
|
{
|
||||||
|
static EditorTools()
|
||||||
|
{
|
||||||
|
InitAssembly();
|
||||||
|
}
|
||||||
|
|
||||||
#region Assembly
|
#region Assembly
|
||||||
|
#if UNITY_2019_4_OR_NEWER
|
||||||
|
private static void InitAssembly()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取带继承关系的所有类的类型
|
||||||
|
/// </summary>
|
||||||
|
public static List<Type> GetAssignableTypes(System.Type parentType)
|
||||||
|
{
|
||||||
|
TypeCache.TypeCollection collection = TypeCache.GetTypesDerivedFrom(parentType);
|
||||||
|
return collection.ToList();
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
private static readonly List<Type> _cacheTypes = new List<Type>(10000);
|
||||||
|
private static void InitAssembly()
|
||||||
|
{
|
||||||
|
Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
|
||||||
|
foreach (Assembly assembly in assemblies)
|
||||||
|
{
|
||||||
|
List<Type> types = assembly.GetTypes().ToList();
|
||||||
|
_cacheTypes.AddRange(types);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取带继承关系的所有类的类型
|
||||||
|
/// </summary>
|
||||||
|
public static List<Type> GetAssignableTypes(System.Type parentType)
|
||||||
|
{
|
||||||
|
List<Type> result = new List<Type>();
|
||||||
|
for (int i = 0; i < _cacheTypes.Count; i++)
|
||||||
|
{
|
||||||
|
Type type = _cacheTypes[i];
|
||||||
|
if (parentType.IsAssignableFrom(type))
|
||||||
|
{
|
||||||
|
if (type.Name == parentType.Name)
|
||||||
|
continue;
|
||||||
|
result.Add(type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 调用私有的静态方法
|
/// 调用私有的静态方法
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -190,7 +240,7 @@ namespace YooAsset.Editor
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region 控制台
|
#region EditorConsole
|
||||||
private static MethodInfo _clearConsoleMethod;
|
private static MethodInfo _clearConsoleMethod;
|
||||||
private static MethodInfo ClearConsoleMethod
|
private static MethodInfo ClearConsoleMethod
|
||||||
{
|
{
|
||||||
|
@ -551,40 +601,6 @@ namespace YooAsset.Editor
|
||||||
}
|
}
|
||||||
return string.Empty;
|
return string.Empty;
|
||||||
}
|
}
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region 字符串
|
|
||||||
/// <summary>
|
|
||||||
/// 是否含有中文
|
|
||||||
/// </summary>
|
|
||||||
public static bool IncludeChinese(string content)
|
|
||||||
{
|
|
||||||
foreach (var c in content)
|
|
||||||
{
|
|
||||||
if (c >= 0x4e00 && c <= 0x9fbb)
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 是否是数字
|
|
||||||
/// </summary>
|
|
||||||
public static bool IsNumber(string content)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(content))
|
|
||||||
return false;
|
|
||||||
string pattern = @"^\d*$";
|
|
||||||
return Regex.IsMatch(content, pattern);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 首字母大写
|
|
||||||
/// </summary>
|
|
||||||
public static string Capitalize(string content)
|
|
||||||
{
|
|
||||||
return content.Substring(0, 1).ToUpper() + (content.Length > 1 ? content.Substring(1).ToLower() : "");
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 截取字符串
|
/// 截取字符串
|
||||||
|
@ -594,7 +610,7 @@ namespace YooAsset.Editor
|
||||||
/// <param name="key">关键字</param>
|
/// <param name="key">关键字</param>
|
||||||
/// <param name="includeKey">分割的结果里是否包含关键字</param>
|
/// <param name="includeKey">分割的结果里是否包含关键字</param>
|
||||||
/// <param name="searchBegin">是否使用初始匹配的位置,否则使用末尾匹配的位置</param>
|
/// <param name="searchBegin">是否使用初始匹配的位置,否则使用末尾匹配的位置</param>
|
||||||
public static string Substring(string content, string key, bool includeKey, bool firstMatch = true)
|
private static string Substring(string content, string key, bool includeKey, bool firstMatch = true)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(key))
|
if (string.IsNullOrEmpty(key))
|
||||||
return content;
|
return content;
|
||||||
|
@ -614,6 +630,7 @@ namespace YooAsset.Editor
|
||||||
else
|
else
|
||||||
return content.Substring(startIndex + key.Length);
|
return content.Substring(startIndex + key.Length);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -15,7 +15,7 @@ namespace YooAsset
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 编辑器下的模拟模式
|
/// 编辑器下的模拟模式
|
||||||
/// 注意:在初始化的时候自动构建真机运行环境。
|
/// 注意:在初始化的时候自动构建真机模拟环境。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
EditorSimulateMode,
|
EditorSimulateMode,
|
||||||
|
|
||||||
|
@ -122,7 +122,7 @@ namespace YooAsset
|
||||||
_locationServices = parameters.LocationServices;
|
_locationServices = parameters.LocationServices;
|
||||||
|
|
||||||
#if !UNITY_EDITOR
|
#if !UNITY_EDITOR
|
||||||
if (parameters is EditorPlayModeParameters)
|
if (parameters is EditorSimulateModeParameters)
|
||||||
throw new Exception($"Editor play mode only support unity editor.");
|
throw new Exception($"Editor play mode only support unity editor.");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue