我目前正在将Unity游戏移植到WinRT /通用Windows平台(UWP)或您现在称之为的任何内容。 我的游戏使用来自资产商店的插件,该插件大量使用反射,我遇到的问题是属性FieldInfo.FieldHandle不存在。
例如,这是一个使用FieldHandle属性
的方法public void InitFromComponent(Component component)
{
m_ComponentType = component.GetType();
m_Fields.Clear();
foreach (FieldInfo f in m_ComponentType.GetFields())
{
if (f.IsPublic)
{
if (f.FieldType == typeof(float)
|| f.FieldType == typeof(Vector4)
|| f.FieldType == typeof(Vector3)
|| f.FieldType == typeof(Vector2)
|| f.FieldType == typeof(int)
|| f.FieldType == typeof(bool)
|| f.FieldType == typeof(string))
{
m_Fields.Add(new Field(f.FieldHandle, f.GetValue(component)));
}
}
}
}
public Field(RuntimeFieldHandle fieldHandle, object args)
{
FieldHandle = fieldHandle;
Args = args;
}
那么有没有办法在WinRT上获取RuntimeFieldHandle?