我正在创建一个 GUI,用于在受UnityEvent GUI启发的 Unity 自定义EditorWindow中选择一个函数。我无法让UnityEvent本身工作;使用EditorGUILayout.PropertyField并将UnityEvent成员作为序列化属性引用会产生一个空的折叠。
我选择了一个有效的函数,但我不知道如何允许用户指定函数参数参数。
using System.Reflection;
int functionIndex = 0;
MethodInfo[] methods = typeof(LvlGenFunctions).GetMethods(BindingFlags.Public | BindingFlags.Static | BindingFlags.DeclaredOnly);
string methodNames = new string[methods.Length];
for(int i = 0; i < methods.Length; ++i)
{
methodNames[i] = methods[i].Name;
}
functionIndex = EditorGUILayout.Popup(functionIndex, methodNames);
methods[functionIndex].Invoke(null, null);
我可以获得ParameterInfo和ParameterType,但我不知道如何创建输入 GUI 字段来指定适当的参数参数。
如何为类型由反射确定的参数创建 Unity IMGUI 输入字段?