Unity 报错之 The same field name is serialized multiple times in the class or its parent class.

Unity 报错之 The same field name is serialized multiple times in the class or its parent class.

Unity 报错之 同一字段名在类或其父级中序列化多次


报错图片:

Unity 报错之 The same field name is serialized multiple times in the class or its parent class.

报错代码:
public class BaseClass : MonoBehaviour {

    public GameObject gameStart;
}

public class SubClass : BaseClass
{
    //不管是否是同一类型都会报这个错误.
    public GameObject gameStart;
    //public Transform gameStart;
}

在写子类代码时,VS会提示我们父类中有此成员,有意隐藏请使用关键字new,如下图:

Unity 报错之 The same field name is serialized multiple times in the class or its parent class.


解决方案:直接使用父类的定义,若不满足需求则可在子类中重新起名即可.

PS:我遇到这个问题时,怎么修改都不好用,最后重启了下Unity就好了,就很奇怪啊…

Unity 报错之 The same field name is serialized multiple times in the class or its parent class.Unity 报错之 The same field name is serialized multiple times in the class or its parent class. Czhenya 博客专家 发布了446 篇原创文章 · 获赞 630 · 访问量 50万+ 他的留言板 关注
上一篇:Find a multiple POJ - 2356


下一篇:POJ 1426 Find The Multiple