完成按键输入按键显示
This commit is contained in:
@@ -1,33 +0,0 @@
|
||||
using System;
|
||||
using FairyGUI;
|
||||
using NBC;
|
||||
using UIPanel = NBC.UIPanel;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Method)]
|
||||
public class UIInputListenAttribute : BaseAttribute
|
||||
{
|
||||
}
|
||||
|
||||
public static class UIInputExtensions
|
||||
{
|
||||
public static void AutoListenInput(this GComponent panel)
|
||||
{
|
||||
var ms = Reflection.GetMethodsWithUIInputAttribute(panel.GetType(), typeof(UIInputListenAttribute));
|
||||
foreach (var method in ms)
|
||||
{
|
||||
Log.Error(method.Name);
|
||||
}
|
||||
}
|
||||
|
||||
public static void AutoListenInput(this UIPanel panel)
|
||||
{
|
||||
var ms = Reflection.GetMethodsWithUIInputAttribute(panel.GetType(), typeof(UIInputListenAttribute));
|
||||
foreach (var method in ms)
|
||||
{
|
||||
Log.Error(method.Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e9bfb9f042814fb787428551c801aada
|
||||
timeCreated: 1748944711
|
||||
@@ -54,7 +54,8 @@ namespace NBF
|
||||
}
|
||||
|
||||
// 获取所有方法,包括公共、非公共、实例和静态方法
|
||||
MethodInfo[] allMethods = classType.GetMethods(BindingFlags.Public | BindingFlags.NonPublic);
|
||||
MethodInfo[] allMethods =
|
||||
classType.GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
|
||||
|
||||
foreach (MethodInfo method in allMethods)
|
||||
{
|
||||
@@ -66,5 +67,35 @@ namespace NBF
|
||||
|
||||
return methodsWithAttribute;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取所有标记指定特性的方法
|
||||
/// </summary>
|
||||
/// <param name="classType">查找类</param>
|
||||
/// <returns></returns>
|
||||
public static Dictionary<MethodInfo, T> GetMethodsAttribute<T>(Type classType) where T : Attribute
|
||||
{
|
||||
Dictionary<MethodInfo, T> methodsWithAttribute = new Dictionary<MethodInfo, T>();
|
||||
|
||||
if (classType == null)
|
||||
{
|
||||
return methodsWithAttribute;
|
||||
}
|
||||
|
||||
// 获取所有方法,包括公共、非公共、实例和静态方法
|
||||
MethodInfo[] allMethods =
|
||||
classType.GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
|
||||
|
||||
foreach (MethodInfo method in allMethods)
|
||||
{
|
||||
var attribute = method.GetCustomAttribute<T>();
|
||||
if (attribute != null)
|
||||
{
|
||||
methodsWithAttribute[method] = attribute;
|
||||
}
|
||||
}
|
||||
|
||||
return methodsWithAttribute;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user