【发布时间】:2019-09-04 03:42:36
【问题描述】:
所以我有一个 ComponenetCopier 脚本,复制脚本真是太棒了。
问题是当我构建我的游戏时它不起作用,它只是丢弃以下错误并中止该过程,但以下异常:
System.ArgumentException:在 System.Reflection.MonoProperty 中找不到“hideFlags”的获取方法
它死亡的代码在这里:
PropertyInfo[] properties = type.GetProperties();
Debug.Log("Do i die here?");
foreach (PropertyInfo property in properties)
{
property.SetValue(myNew_Component, property.GetValue(original, null), null);
}
当它在编辑器模式下工作时,我不知道它为什么会失败,但这让我困扰了好几天。 非常感谢您的帮助...
Ps:我正在使用反射复制我的组件。
【问题讨论】:
-
我实例化一个游戏对象,然后当不再需要该 GamObject 时,我将它的一些组件复制到一个新对象。
-
嗯,这听起来应该有更好的设计来实现你想要实现的目标..
标签: c# unity3d reflection