Fist Sub
based on aimbot multi seane
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts.Runtime
|
||||
{
|
||||
public static class ColorUtil
|
||||
{
|
||||
public static readonly Color32 clearColor32 = new Color32(0, 0, 0, 0);
|
||||
public static readonly Vector2 zeroVector2 = Vector2.zero;
|
||||
/// <summary>
|
||||
/// Convert the html string to color.
|
||||
/// |将字符串颜色值转成Color。
|
||||
/// </summary>
|
||||
/// <param name="hexColorStr"></param>
|
||||
/// <returns></returns>
|
||||
public static Color32 GetColor(string hexColorStr)
|
||||
{
|
||||
Color color;
|
||||
ColorUtility.TryParseHtmlString(hexColorStr, out color);
|
||||
return (Color32) color;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4260c3b8fdaff435a8bc10375b812bd8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,166 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace XCharts.Runtime
|
||||
{
|
||||
public static class DateTimeUtil
|
||||
{
|
||||
//private static readonly DateTime k_DateTime1970 = TimeZoneInfo.ConvertTime(new DateTime(1970, 1, 1), TimeZoneInfo.Local);
|
||||
private static readonly DateTime k_DateTime1970 = new DateTime(1970, 1, 1);
|
||||
public static readonly int ONE_SECOND = 1;
|
||||
public static readonly int ONE_MINUTE = ONE_SECOND * 60;
|
||||
public static readonly int ONE_HOUR = ONE_MINUTE * 60;
|
||||
public static readonly int ONE_DAY = ONE_HOUR * 24;
|
||||
public static readonly int ONE_MONTH = ONE_DAY * 30;
|
||||
public static readonly int ONE_YEAR = ONE_DAY * 365;
|
||||
public static readonly int MIN_TIME_SPLIT_NUMBER = 4;
|
||||
|
||||
private static string s_YearDateFormatter = "yyyy";
|
||||
//private static string s_MonthDateFormatter = "MM";
|
||||
//private static string s_DayDateFormatter = "dd";
|
||||
private static string s_HourDateFormatter = "HH:mm";
|
||||
private static string s_MinuteDateFormatter = "HH:mm";
|
||||
private static string s_SecondDateFormatter = "HH:mm:ss";
|
||||
//private static string s_DateFormatter = "yyyy-MM-dd HH:mm:ss";
|
||||
|
||||
public static int GetTimestamp()
|
||||
{
|
||||
return (int) (DateTime.Now - k_DateTime1970).TotalSeconds;
|
||||
}
|
||||
|
||||
public static int GetTimestamp(DateTime time)
|
||||
{
|
||||
return (int) (time - k_DateTime1970).TotalSeconds;
|
||||
}
|
||||
|
||||
public static DateTime GetDateTime(int timestamp)
|
||||
{
|
||||
long span = ((long) timestamp) * 10000000;
|
||||
return k_DateTime1970.Add(new TimeSpan(span));
|
||||
}
|
||||
|
||||
internal static string GetDateTimeFormatString(DateTime dateTime, double range)
|
||||
{
|
||||
var dateString = String.Empty;
|
||||
if (range >= DateTimeUtil.ONE_YEAR * DateTimeUtil.MIN_TIME_SPLIT_NUMBER)
|
||||
{
|
||||
dateString = dateTime.ToString(s_YearDateFormatter);
|
||||
}
|
||||
else if (range >= DateTimeUtil.ONE_MONTH * DateTimeUtil.MIN_TIME_SPLIT_NUMBER)
|
||||
{
|
||||
dateString = dateTime.Month == 1 ?
|
||||
dateTime.ToString(s_YearDateFormatter) :
|
||||
XCSettings.lang.GetMonthAbbr(dateTime.Month);
|
||||
}
|
||||
else if (range >= DateTimeUtil.ONE_DAY * DateTimeUtil.MIN_TIME_SPLIT_NUMBER)
|
||||
{
|
||||
dateString = dateTime.Day == 1 ?
|
||||
XCSettings.lang.GetMonthAbbr(dateTime.Month) :
|
||||
XCSettings.lang.GetDay(dateTime.Day);
|
||||
}
|
||||
else if (range >= DateTimeUtil.ONE_HOUR * DateTimeUtil.MIN_TIME_SPLIT_NUMBER)
|
||||
{
|
||||
dateString = dateTime.ToString(s_HourDateFormatter);
|
||||
}
|
||||
else if (range >= DateTimeUtil.ONE_MINUTE * DateTimeUtil.MIN_TIME_SPLIT_NUMBER)
|
||||
{
|
||||
dateString = dateTime.ToString(s_MinuteDateFormatter);
|
||||
}
|
||||
else
|
||||
{
|
||||
dateString = dateTime.ToString(s_SecondDateFormatter);
|
||||
}
|
||||
return dateString;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据给定的最大最小时间戳范围,计算合适的Tick值
|
||||
/// </summary>
|
||||
/// <param name="list"></param>
|
||||
/// <param name="minTimestamp"></param>
|
||||
/// <param name="maxTimestamp"></param>
|
||||
/// <param name="splitNumber"></param>
|
||||
internal static void UpdateTimeAxisDateTimeList(List<double> list, int minTimestamp, int maxTimestamp, int splitNumber)
|
||||
{
|
||||
list.Clear();
|
||||
var range = maxTimestamp - minTimestamp;
|
||||
if (range <= 0) return;
|
||||
if (splitNumber <= 0) splitNumber = 1;
|
||||
var dtMin = DateTimeUtil.GetDateTime(minTimestamp);
|
||||
var dtMax = DateTimeUtil.GetDateTime(maxTimestamp);
|
||||
if (range >= ONE_YEAR * MIN_TIME_SPLIT_NUMBER)
|
||||
{
|
||||
var num = Math.Max(range / (splitNumber * ONE_YEAR), 1);
|
||||
var dtStart = new DateTime(dtMin.Year + 1, 1, 1);
|
||||
while (dtStart.Ticks < dtMax.Ticks)
|
||||
{
|
||||
list.Add(DateTimeUtil.GetTimestamp(dtStart));
|
||||
dtStart = dtStart.AddYears(num);
|
||||
}
|
||||
}
|
||||
else if (range >= ONE_MONTH * MIN_TIME_SPLIT_NUMBER)
|
||||
{
|
||||
var num = Math.Max(range / (splitNumber * ONE_MONTH), 1);
|
||||
var dtStart = new DateTime(dtMin.Year, dtMin.Month, 1).AddMonths(1);
|
||||
while (dtStart.Ticks < dtMax.Ticks)
|
||||
{
|
||||
list.Add(DateTimeUtil.GetTimestamp(dtStart));
|
||||
dtStart = dtStart.AddMonths(num);
|
||||
}
|
||||
}
|
||||
else if (range >= ONE_DAY * MIN_TIME_SPLIT_NUMBER)
|
||||
{
|
||||
var tick = GetTickSecond(range, splitNumber, ONE_DAY);
|
||||
var startTimestamp = (minTimestamp - minTimestamp % tick) + tick;
|
||||
AddTickTimestamp(list, startTimestamp, maxTimestamp, tick);
|
||||
}
|
||||
else if (range >= ONE_HOUR * MIN_TIME_SPLIT_NUMBER)
|
||||
{
|
||||
var tick = GetTickSecond(range, splitNumber, ONE_HOUR);
|
||||
var startTimestamp = (minTimestamp - minTimestamp % tick) + tick;
|
||||
AddTickTimestamp(list, startTimestamp, maxTimestamp, tick);
|
||||
}
|
||||
else if (range >= ONE_MINUTE * MIN_TIME_SPLIT_NUMBER)
|
||||
{
|
||||
var tick = GetTickSecond(range, splitNumber, ONE_MINUTE);
|
||||
var startTimestamp = (minTimestamp - minTimestamp % tick) + tick;
|
||||
AddTickTimestamp(list, startTimestamp, maxTimestamp, tick);
|
||||
}
|
||||
else
|
||||
{
|
||||
var tick = GetTickSecond(range, splitNumber, ONE_SECOND);
|
||||
var startTimestamp = (minTimestamp - minTimestamp % tick) + tick;
|
||||
AddTickTimestamp(list, startTimestamp, maxTimestamp, tick);
|
||||
}
|
||||
}
|
||||
|
||||
private static int GetTickSecond(int range, int splitNumber, int tickSecond)
|
||||
{
|
||||
var num = 0;
|
||||
if (splitNumber > 0)
|
||||
{
|
||||
num = Math.Max(range / (splitNumber * tickSecond), 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
num = 1;
|
||||
var tick = tickSecond;
|
||||
while (range / tick > 8)
|
||||
{
|
||||
num++;
|
||||
tick = num * tickSecond;
|
||||
}
|
||||
}
|
||||
return num * tickSecond;
|
||||
}
|
||||
|
||||
private static void AddTickTimestamp(List<double> list, int startTimestamp, int maxTimestamp, int tickSecond)
|
||||
{
|
||||
while (startTimestamp < maxTimestamp)
|
||||
{
|
||||
list.Add(startTimestamp);
|
||||
startTimestamp += tickSecond;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0f0ac80f189a04b5c826f40c8bc8af64
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,89 @@
|
||||
#if UNITY_EDITOR
|
||||
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts.Runtime
|
||||
{
|
||||
public static class DefineSymbolsUtil
|
||||
{
|
||||
private static readonly StringBuilder s_StringBuilder = new StringBuilder();
|
||||
|
||||
public static void AddGlobalDefine(string symbol)
|
||||
{
|
||||
var flag = false;
|
||||
var num = 0;
|
||||
foreach (var buildTargetGroup in (BuildTargetGroup[]) Enum.GetValues(typeof(BuildTargetGroup)))
|
||||
{
|
||||
if (IsValidBuildTargetGroup(buildTargetGroup))
|
||||
{
|
||||
var symbols = PlayerSettings.GetScriptingDefineSymbolsForGroup(buildTargetGroup);
|
||||
symbols = symbols.Replace(" ", "");
|
||||
if (Array.IndexOf(symbols.Split(';'), symbol) != -1) continue;
|
||||
flag = true;
|
||||
num++;
|
||||
var defines = symbols + (symbols.Length > 0 ? ";" + symbol : symbol);
|
||||
PlayerSettings.SetScriptingDefineSymbolsForGroup(buildTargetGroup, defines);
|
||||
}
|
||||
}
|
||||
if (flag)
|
||||
{
|
||||
Debug.LogFormat("Added global define symbol \"{0}\" to {1} BuildTargetGroups.", symbol, num);
|
||||
}
|
||||
}
|
||||
|
||||
public static void RemoveGlobalDefine(string symbol)
|
||||
{
|
||||
var flag = false;
|
||||
var num = 0;
|
||||
foreach (var buildTargetGroup in (BuildTargetGroup[]) Enum.GetValues(typeof(BuildTargetGroup)))
|
||||
{
|
||||
if (IsValidBuildTargetGroup(buildTargetGroup))
|
||||
{
|
||||
var symbols = PlayerSettings.GetScriptingDefineSymbolsForGroup(buildTargetGroup).Split(';');
|
||||
if (Array.IndexOf(symbols, symbol) == -1) continue;
|
||||
flag = true;
|
||||
num++;
|
||||
s_StringBuilder.Length = 0;
|
||||
foreach (var str in symbols)
|
||||
{
|
||||
if (!str.Equals(symbol))
|
||||
{
|
||||
if (s_StringBuilder.Length > 0) s_StringBuilder.Append(";");
|
||||
s_StringBuilder.Append(str);
|
||||
}
|
||||
}
|
||||
PlayerSettings.SetScriptingDefineSymbolsForGroup(buildTargetGroup, s_StringBuilder.ToString());
|
||||
}
|
||||
}
|
||||
if (flag)
|
||||
{
|
||||
Debug.LogFormat("Removed global define symbol \"{0}\" to {1} BuildTargetGroups.", symbol, num);
|
||||
}
|
||||
}
|
||||
|
||||
private static bool IsValidBuildTargetGroup(BuildTargetGroup group)
|
||||
{
|
||||
if (group == BuildTargetGroup.Unknown) return false;
|
||||
var type = Type.GetType("UnityEditor.Modules.ModuleManager, UnityEditor.dll");
|
||||
if (type == null) return true;
|
||||
var method1 = type.GetMethod("GetTargetStringFromBuildTargetGroup", BindingFlags.Static | BindingFlags.NonPublic);
|
||||
var method2 = typeof(PlayerSettings).GetMethod("GetPlatformName", BindingFlags.Static | BindingFlags.NonPublic);
|
||||
if (method1 == null || method2 == null) return true;
|
||||
var str1 = (string) method1.Invoke(null, new object[] { group });
|
||||
var str2 = (string) method2.Invoke(null, new object[] { group });
|
||||
if (string.IsNullOrEmpty(str1))
|
||||
{
|
||||
return !string.IsNullOrEmpty(str2);
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 91545951242fa441eb1a9bba3a6ad5a7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,52 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts.Runtime
|
||||
{
|
||||
public static class PropertyUtil
|
||||
{
|
||||
public static bool SetColor(ref Color currentValue, Color newValue)
|
||||
{
|
||||
if (currentValue.r == newValue.r && currentValue.g == newValue.g && currentValue.b == newValue.b && currentValue.a == newValue.a)
|
||||
return false;
|
||||
|
||||
currentValue = newValue;
|
||||
return true;
|
||||
}
|
||||
|
||||
public static bool SetColor(ref Color32 currentValue, Color32 newValue)
|
||||
{
|
||||
if (currentValue.r == newValue.r && currentValue.g == newValue.g && currentValue.b == newValue.b && currentValue.a == newValue.a)
|
||||
return false;
|
||||
|
||||
currentValue = newValue;
|
||||
return true;
|
||||
}
|
||||
|
||||
public static bool SetStruct<T>(ref T currentValue, T newValue) where T : struct
|
||||
{
|
||||
if (EqualityComparer<T>.Default.Equals(currentValue, newValue))
|
||||
return false;
|
||||
|
||||
currentValue = newValue;
|
||||
return true;
|
||||
}
|
||||
|
||||
public static bool SetClass<T>(ref T currentValue, T newValue, bool notNull = false) where T : class
|
||||
{
|
||||
if (notNull)
|
||||
{
|
||||
if (newValue == null)
|
||||
{
|
||||
Debug.LogError("can not be null.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if ((currentValue == null && newValue == null) || (currentValue != null && currentValue.Equals(newValue)))
|
||||
return false;
|
||||
|
||||
currentValue = newValue;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b1f52eadd805d43aea47947fb81e761f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,133 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts.Runtime
|
||||
{
|
||||
public static class ReflectionUtil
|
||||
{
|
||||
private static Dictionary<object, MethodInfo> listClearMethodInfoCaches = new Dictionary<object, MethodInfo>();
|
||||
private static Dictionary<object, MethodInfo> listAddMethodInfoCaches = new Dictionary<object, MethodInfo>();
|
||||
|
||||
public static void InvokeListClear(object obj, FieldInfo field)
|
||||
{
|
||||
var list = field.GetValue(obj);
|
||||
MethodInfo method;
|
||||
if (!listClearMethodInfoCaches.TryGetValue(list, out method))
|
||||
{
|
||||
method = list.GetType().GetMethod("Clear");
|
||||
listClearMethodInfoCaches[list] = method;
|
||||
}
|
||||
method.Invoke(list, new object[] { });
|
||||
}
|
||||
public static int InvokeListCount(object obj, FieldInfo field)
|
||||
{
|
||||
var list = field.GetValue(obj);
|
||||
return (int) list.GetType().GetProperty("Count").GetValue(list, null);
|
||||
}
|
||||
|
||||
public static void InvokeListAdd(object obj, FieldInfo field, object item)
|
||||
{
|
||||
var list = field.GetValue(obj);
|
||||
MethodInfo method;
|
||||
if (!listAddMethodInfoCaches.TryGetValue(list, out method))
|
||||
{
|
||||
method = list.GetType().GetMethod("Add");
|
||||
listAddMethodInfoCaches[list] = method;
|
||||
}
|
||||
method.Invoke(list, new object[] { item });
|
||||
}
|
||||
|
||||
public static T InvokeListGet<T>(object obj, FieldInfo field, int i)
|
||||
{
|
||||
var list = field.GetValue(obj);
|
||||
var item = list.GetType().GetProperty("Item").GetValue(list, new object[] { i });
|
||||
return (T) item;
|
||||
}
|
||||
|
||||
public static void InvokeListAddTo<T>(object obj, FieldInfo field, Action<T> callback)
|
||||
{
|
||||
var list = field.GetValue(obj);
|
||||
var listType = list.GetType();
|
||||
var count = Convert.ToInt32(listType.GetProperty("Count").GetValue(list, null));
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
var item = listType.GetProperty("Item").GetValue(list, new object[] { i });
|
||||
callback((T) item);
|
||||
}
|
||||
}
|
||||
|
||||
public static object DeepCloneSerializeField(object obj)
|
||||
{
|
||||
if (obj == null)
|
||||
return null;
|
||||
|
||||
var type = obj.GetType();
|
||||
if (type.IsValueType || type == typeof(string))
|
||||
{
|
||||
return obj;
|
||||
}
|
||||
else if (type.IsArray)
|
||||
{
|
||||
var elementType = Type.GetType(type.FullName.Replace("[]", string.Empty));
|
||||
var array = obj as Array;
|
||||
var copied = Array.CreateInstance(elementType, array.Length);
|
||||
for (int i = 0; i < array.Length; i++)
|
||||
copied.SetValue(DeepCloneSerializeField(array.GetValue(i)), i);
|
||||
return Convert.ChangeType(copied, obj.GetType());
|
||||
}
|
||||
else if (type.IsClass)
|
||||
{
|
||||
object returnObj;
|
||||
var listObj = obj as IList;
|
||||
if (listObj != null)
|
||||
{
|
||||
var properties = type.GetProperties();
|
||||
var customList = typeof(List<>).MakeGenericType((properties[properties.Length - 1]).PropertyType);
|
||||
returnObj = (IList) Activator.CreateInstance(customList);
|
||||
var list = (IList) returnObj;
|
||||
foreach (var item in ((IList) obj))
|
||||
{
|
||||
if (item == null)
|
||||
continue;
|
||||
list.Add(DeepCloneSerializeField(item));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
returnObj = Activator.CreateInstance(type);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return null;
|
||||
}
|
||||
var fileds = type.GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
for (int i = 0; i < fileds.Length; i++)
|
||||
{
|
||||
var field = fileds[i];
|
||||
if (!field.IsDefined(typeof(SerializeField), false))
|
||||
continue;
|
||||
var filedValue = field.GetValue(obj);
|
||||
if (filedValue == null)
|
||||
{
|
||||
field.SetValue(returnObj, filedValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
field.SetValue(returnObj, DeepCloneSerializeField(filedValue));
|
||||
}
|
||||
}
|
||||
}
|
||||
return returnObj;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new ArgumentException("DeepCloneSerializeField: Unknown type:" + type + "," + obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 03acc4ee710ff4bad9a1740391c86cb9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,87 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Assertions;
|
||||
|
||||
namespace XCharts.Runtime
|
||||
{
|
||||
public static class RuntimeUtil
|
||||
{
|
||||
public static bool HasSubclass(Type type)
|
||||
{
|
||||
var typeMap = GetAllTypesDerivedFrom(type);
|
||||
foreach (var t in typeMap)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static IEnumerable<Type> GetAllTypesDerivedFrom<T>()
|
||||
{
|
||||
#if UNITY_EDITOR && UNITY_2019_2_OR_NEWER
|
||||
return UnityEditor.TypeCache.GetTypesDerivedFrom<T>();
|
||||
#else
|
||||
return GetAllAssemblyTypes().Where(t => t.IsSubclassOf(typeof(T)));
|
||||
#endif
|
||||
}
|
||||
public static IEnumerable<Type> GetAllTypesDerivedFrom(Type type)
|
||||
{
|
||||
#if UNITY_EDITOR && UNITY_2019_2_OR_NEWER
|
||||
return UnityEditor.TypeCache.GetTypesDerivedFrom(type);
|
||||
#else
|
||||
return GetAllAssemblyTypes().Where(t => t.IsSubclassOf(type));
|
||||
#endif
|
||||
}
|
||||
|
||||
static IEnumerable<Type> m_AssemblyTypes;
|
||||
|
||||
public static IEnumerable<Type> GetAllAssemblyTypes()
|
||||
{
|
||||
if (m_AssemblyTypes == null)
|
||||
{
|
||||
m_AssemblyTypes = AppDomain.CurrentDomain.GetAssemblies()
|
||||
.SelectMany(t =>
|
||||
{
|
||||
var innerTypes = new Type[0];
|
||||
try
|
||||
{
|
||||
innerTypes = t.GetTypes();
|
||||
}
|
||||
catch { }
|
||||
return innerTypes;
|
||||
});
|
||||
}
|
||||
return m_AssemblyTypes;
|
||||
}
|
||||
|
||||
public static T GetAttribute<T>(this Type type, bool check = true) where T : Attribute
|
||||
{
|
||||
if (type.IsDefined(typeof(T), false))
|
||||
return (T) type.GetCustomAttributes(typeof(T), false) [0];
|
||||
else
|
||||
{
|
||||
if (check)
|
||||
Assert.IsTrue(false, "Attribute not found:" + type.Name);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
public static T GetAttribute<T>(this MemberInfo type, bool check = true) where T : Attribute
|
||||
{
|
||||
if (type.IsDefined(typeof(T), false))
|
||||
return (T) type.GetCustomAttributes(typeof(T), false) [0];
|
||||
else
|
||||
{
|
||||
if (check)
|
||||
Assert.IsTrue(false, "Attribute not found:" + type.Name);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 44becf1664ae64397b44adcf65e6d8d2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user